[Python-Dev] Relative import

Guido van Rossum guido at python.org
Wed Dec 17 19:20:07 EST 2003

> > I think this addresses all the concerns I've seen brought up in this
> > thread so far
> No, it doesn't address my concern that scan-upwards semantics
> should be the default, in the sense of being what should be
> used in the absence of a reason to do otherwise, and should
> therefore have the most straightforward syntax.

It doesn't address that becaseu I don't want that to be the default.
I'm considering adding syntax for relative imports so that the default
import syntax can be absolute only, rather than ambiguous.
IMO scan-upwards as the default is  worse than ambiguous.

> Also, you don't seem to have anything for the explicitly-relative
> case, which might not be strictly necessary, but I think
> I'd feel more comfortable if it were available somehow.

That's why I originally proposed single, double, triple (etc.) leading

> Thinking about the double_underscore names, it might not
> be so bad if they were a bit shorter, e.g.

I *really* don't like using double-underscore names here unless it was
for extremely uncommon cases.

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.

I cannot accept scan-up as default, and I don't think we can come up
with two separate clearly distinguishable non-default syntaxes to
separate scan-up and explicit relative semantics, so you have to pick
one there.

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

More information about the Python-Dev mailing list