Torsten Bronger <[EMAIL PROTECTED]> added the comment:
I have a very similar issue (maybe the same?) at the moment.
Assume the follwing package structure:
main.py
package/
__init__.py [empty]
moduleX.py
moduleY.py
main.py says:
from package import moduleX
moduleX.py says:
from . import moduleY
and moduleY.py says:
from . import moduleX
However, this doesn't work:
[EMAIL PROTECTED]:~/temp/packages-test$ python main.py
Traceback (most recent call last):
File "main.py", line 1, in <module>
from package import moduleX
File "/home/bronger/temp/packages-test/package/moduleX.py", line
1, in <module>
from . import moduleY
File "/home/bronger/temp/packages-test/package/moduleY.py", line
1, in <module>
from . import moduleX
ImportError: cannot import name moduleX
If I turn the relative imports to absolutes ones, it works. But I'd
prefer the relative notation for intra-package imports. That's their
purpose after all.
If you split a large module into chunks, cyclic imports are hardly
avoidable (and there's nothing bad about it; it worked fine before PEP 328).
Note that "import absolute.path.to.module as short" doesn't work either.
So currently, in presence of cyclic imports in a package, the only
remedy is to use the full absolute paths everywhere in the source code,
which is really awkward in my opinion.
----------
nosy: +bronger
____________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue992389>
____________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com