help with relative imports
Robert Kern
robert.kern at gmail.com
Tue Sep 19 14:23:00 EDT 2006
John Salerno wrote:
> I'm reading the "What's New" section of the 2.5 docs, and I'm a little
> confused by the last section of "Absolute and Relative Imports":
>
> -----------------------------------------------
> For example, code in the A.B.C module can do:
>
> from . import D # Imports A.B.D
> from .. import E # Imports A.E
> from ..F import G # Imports A.F.G
> -----------------------------------------------
>
> Can someone explain this? It seems like information is missing. How do
> you know where D, E, F and G are to figure this out? If all you are
> given is A.B.C, and then someone gives you the above three examples,
> what steps do you take to figure out what gets imported from where?
What is ambiguous about A.B.D, A.E, and A.F.G? But if you like:
A/
B/
C.py
D.py
E.py
F/
G.py
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list