[Python-Dev] Relative import

Troy Melhase troy at gci.net
Mon Dec 22 04:03:08 EST 2003


On Sunday 21 December 2003 10:52 pm, Jack Diederich wrote:
> On Sun, Dec 21, 2003 at 08:48:01PM -0800, Guido van Rossum wrote:
> > > I like syntax that reads most important left-to-right, so what about
> > > from MODULE import NAMES as RENAME searching HOW
> > > import NAMES as RENAME from MODULE searching HOW

I like Jack's original idea and I've been chewing on it for a few days.  His 
was:

import NAMES as RENAME from MODULE searching HOW

My humble suggestion:

import NAMES
import NAMES in MODULE [in HOW]
import NAME, OTHER in FOO in RELATIVE
import NAME as RENAME in MODULE in ABSOLUTE

Playing with it:

import sys
import path, stat in os
import AClass, AValue in AModule in __search__
import AType in Package.Library in __absolute__

It emphasizes the name that's imported and it reduces+reuses a keyword.  
Reusing "in" is a stretch, of course, and it reading it twice in the same 
statement might be confusing for some.

I don't really like the dot/triple dot notation... the leading punctuation 
smells perl-ish.  :)


Only-a-random-two-cents-ly yours,

-- 
Troy Melhase, troy at gci.net
--
Merry Christmas!




More information about the Python-Dev mailing list