[Python-Dev] relative import circular problem
Kristján Valur Jónsson
kristjan at ccpgames.com
Mon Apr 1 22:20:34 CEST 2013
I just ran into the issue described in http://stackoverflow.com/questions/6351805/cyclic-module-dependencies-and-relative-imports-in-python.
This is unfortunate, because we have been trying to move towards relative imports in order to aid flexibility in package and library design.
The relative import syntax
(from foo import bar) is a getattr type of lookup (i.e. import foo, then get attr from it).
This is in contrast with absolute import
import foo.bar (get the module foo.bar from sys.modules or import it)
bar = foo.bar
the latter works with partially initialized modules, but not the former, rendering two sibling modules unable to import each other using the relative syntax.
as far as I know, relative imports are only supported using the former (import from) syntax. Are there any plans to alleviate this by allowing proper relative imports? After all, relative imports and packages go hand in hand.
K
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130401/8ff1f735/attachment.html>
More information about the Python-Dev
mailing list