help with relative imports

John Salerno johnjsal at NOSPAMgmail.com
Tue Sep 19 14:01:43 EDT 2006


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?

Thanks,
John



More information about the Python-list mailing list