| Store | Cart

PEP 328: Imports: Multi-Line and Absolute/Relative

From: Josiah Carlson <jcar...@nospam.uci.edu>
Mon, 08 Mar 2004 22:34:26 -0800
>   [-5.dirname.dirname.dirname]filename

The above is relatively clear, though the brackets kind of destroy the 
clarity.  For magical syntax, it isn't bad.  I prefer the standard 
semantics already offered:
from MODULE import NAMES as RENAME searching HOW
import NAMES as RENAME from MODULE searching HOW

Or for backwards compatibility:
from HOW.MODULE import NAMES as RENAME
import HOW.MODULE.NAMES as RENAME


Where HOW is of the form:
-<INTEGER>[.PACKAGE1[.PACKAGE2[...]]]
[PACKAGE1[.PACKAGE2[...]]]

With the search stepping up <integer> path levels, then traversing down 
through the listed packages, not stepping up any path levels when the 
-integer is not given, and raising a SyntaxError for -0 imports.  For 
example:

for HOW:
-1.sibling_package
maps to ../sibling_package/MODULE.(py|pyc|pyo|pyd|so|dll)

-2.uncle_package.cousin_package
maps to ../../uncle_package/cousin_package/MODULE.(ext)

-0.[other stuff]
should raise a SyntaxError

child_package.grandchild_package.great_grandchild_module
maps to ./child_package/grandchild_package/great_grandchild_module.(ext)


I think such behavior is clear enough magical syntax, what do others think?

  - Josiah

Recent Messages in this Thread
Aahz Mar 08, 2004 08:24 pm
John Roth Mar 09, 2004 01:04 am
Aahz Mar 10, 2004 10:49 am
John Roth Mar 10, 2004 01:04 pm
Stephen Horne Mar 10, 2004 04:44 pm
John Roth Mar 10, 2004 06:14 pm
Stephen Horne Mar 09, 2004 01:09 am
Mike Mar 09, 2004 03:39 am
Josiah Carlson Mar 09, 2004 06:34 am
Sean Ross Mar 09, 2004 06:13 pm
Paul Rubin Mar 09, 2004 10:44 pm
Josiah Carlson Mar 10, 2004 04:20 am
Andrew Clover Mar 10, 2004 01:18 pm
Sean Ross Mar 10, 2004 03:11 pm
Josiah Carlson Mar 12, 2004 07:06 am
Thomas Heller Mar 09, 2004 07:41 am
Andrew Clover Mar 09, 2004 10:12 am
Denis S. Otkidach Mar 09, 2004 10:50 am
Gerrit Mar 10, 2004 11:41 am
Anders J. Munch Mar 10, 2004 02:46 pm
Dieter Maurer Mar 11, 2004 10:29 pm
Geoff Howland Mar 14, 2004 12:50 am
Aahz Mar 10, 2004 11:01 am
John Roth Mar 10, 2004 01:13 pm
Messages in this thread