help with relative imports
John Salerno
johnjsal at NOSPAMgmail.com
Tue Sep 19 14:36:05 EDT 2006
Robert Kern wrote:
> What is ambiguous about A.B.D, A.E, and A.F.G? But if you like:
I guess maybe I was looking at it backwards. From the way it was worded,
I thought the only information we had to use was the structure A.B.C,
and then given a statement like:
from . import D
we just had to figure out for ourselves that this results in A.B.D,
instead of, for example, A.C.D, or any other possibility.
But I'm still a little confused about the use of the single or double
period. In this case:
from . import D # Imports A.B.D
from .. import E # Imports A.E
why do you need a single period in the first example, and a double in
the second, if they both are importing from A? If E is directly under A,
couldn't you just use a single period? And since D is nested twice
beneath A (i.e., in A, then in B), wouldn't you need two periods there
instead?
More information about the Python-list
mailing list