[Python-Dev] Re: Relative import

Guido van Rossum guido at python.org
Thu Dec 18 10:50:44 EST 2003

> If that's what you;d like a vote on, I prefer the triple-dot proposal. 
> As far as semantics go, I have no opinion (I don't have any use for
> either option) but I *really* dislike the look of the single dot. I'm
> not a great fan of the triple dot, but it's the lesser of the two
> evils.

Your vote doesn't help me; the triple dot proposal is semantically
different from the single dot.

> I have to admit to some confusion here, though. At the moment, the
> following works:
>     pkg\__init__.py:
>         print "importing pkg"
>         import a
>     pkg\a.py:
>         print "importing a"
>         import b
>     pkg\b.py:
>         print "importing b"
>     >>> import pkg
>     importing pkg
>     importing a
>     importing b
> Is the proposal that any of this *stop* working? I assume not. 
> Otherwise, I'm -1 on the whole thing. I see no reason to break this
> usage, and good reason (I can rename pkg - before final release,
> obviously - without needing to do a search-and-replace edit on
> everything in the package).

The idea is indeed to break this in Python 3.0 (but not earlier for
backwards compatibility reasons).  In 3.0, you would have to (and in
2.4 perhaps you could) write this as

  from . import a


  from ... import a

depending on which proposal is accepted.

> I think this whole thing needs a PEP, though. If only to be completely
> clear on what is and is not changing, and to record discarded options.

Correct.  I have no time to write it though.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list