[Python-Dev] Re: PEP 328 -- relative and multi-line import
goodger at python.org
Sat Apr 3 10:44:13 EST 2004
> David Goodger <goodger at python.org> writes:
>> In other words, is the "Y" here acceptable
>> (where Y is a sibling to the current module's package)?
>> from ..Y import X
David Abrahams wrote:
> Wouldn't that have to be
> from ...Y import X
> ^-------------separator, as in A.B
Aha! My confusion is confirmed.
I hadn't thought of requiring a separator "."; that seems like
overloading of meaning. I understood the syntax as Aahz
describes it, so a single leading "." means "current package"
(i.e., sibling of current module), ".." means "parent package"
or "up one level", etc.
> I'm thinking some other syntax is needed to represent upward travel
> in the hierarchy, e.g.
> from ^.Y import X
That has a certain elegance to it. So ".Y" would mean import
from current package, "^.Y" would mean import from parent
package, "^^.Y" from parent's parent package, etc.
I don't want to reopen debate needlessly, but the overloading
of the meaning of "." *is* a bit confusing here.
Whatever makes sense to Guido will eventually make sense to me,
so I'm not worried.
-- David Goodger
More information about the Python-Dev