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

John Roth newsgroups at
Wed Mar 10 14:04:22 CET 2004

"Aahz" <aahz at> wrote in message
news:c2mrrq$1k7$1 at
> In article <104q64b2uf3nl0b at>,
> John Roth <newsgroups at> wrote:
> >
> >I think this is a serious conceptual issue, and I'd prefer to not
> >support upwards references at all.  That doesn't mean they should be
> >prohibited, but if someone wants to dig a pit for himself with circular
> >coupling across module hierarchies, then he should be required to
> >wield the shovel himself. It is not, after all, that difficult to
> >sort through sys.modules to figure out where you are in the import
> >hierarchy.
> While that makes some sense, what about "uncle" references within the
> current package?

I'm not sure what you mean by "Uncle." The term usually
means "parent's brother" or "some son of your grandparents
other than your father" so I'd assume it would go up one
directory and then sideways, which would require going up
another directory.

If you are refering to another module in the same directory
that this one came from, then I'd code that as:

import *.foo

However, possibly you meant "cousin?" I can see a
use case for that as a packaging convenience. To make
this concrete, let's assume we have a package named
"A" with subpackages named "B" and "C". If B
contains module "B1", then we might want to be
able to refer to module C1 in package C from module
B1 in package B as if it was originally on the pythonpath.

If B and C are both on the pythonpath, then you need
to say:

import C.C1

However, if they aren't, then you would have to say
something like:

import ^.C.C1

> >That leaves references to the current package.  I'm going to suggest an
> >"*" as an indicator for "this package." The reason for an asterisk is
> >my background in mainframe assembler: it means "here" in that language,
> >so I'm obviously not particularly attached to it. It's also already in
> >use in the "from foo import *" syntax.
> >
> >A reference beginning in the current directory is thus:
> >
> >import *.spam.eggs
> That's functionally equivalent to the suggested
> import .spam.eggs

Certainly. An * is easier to see on the screen.
I believe that was one of the issues with the single
dot notation.

John Roth

> -- 
> Aahz (aahz at           <*>
> "Do not taunt happy fun for loops. Do not change lists you are looping
> --Remco Gerlich, comp.lang.python

More information about the Python-list mailing list