[Python-Dev] Re: Relative import (original) (raw)

Paul Moore pf_moore at yahoo.co.uk
Thu Dec 18 09:03:26 EST 2003


Guido van Rossum <guido at python.org> writes:

There are two proposals that I can live with: my original proposal with the leading dots counting the number of levels up, or the triple-dot proposal with scan-up semantics. In both cases, the default semantics would switch to absolute for Python 3.0.

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.

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).

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.

Paul.

This signature intentionally left blank



More information about the Python-Dev mailing list