[Python-Dev] Re: Python-Dev Digest, Vol 5, Issue 57

Werner Schiendl ws-news at gmx.at
Tue Dec 16 16:02:30 EST 2003


"Edward Loper" <edloper at gradient.cis.upenn.edu> wrote
> Guido said:
> > [...]  I propose not to change from-less import.
> What's the motivation for restricting it to from-imports?  I suspect
> that this will cause confusion, and it doesn't feel self-consistent to
> me: why can you call a module ".foo" in one context, and not in
> another?  In particular, I think that if people see that you can do:
>      from .foo import *
> Then they'll assume that they can also do:
>      import .foo

The problem is probably, to what name should the module be bound?
Variable names are not allowed to contain a leading dot.

But it would be possible to say:

import .foo as my_foo
import foo

and access both through modules through the name they're bound to.

Therefore I'd propose to allow relative from-less imports, but require
them to always use the "as" clause.



More information about the Python-Dev mailing list