Message301614
Consider the following Python project:
bugtest/
__init__.py (Contents: from .foo import *)
foo/
__init__.py (Contents: from .foo import *)
foo.py (Contents: <empty file>)
Then in a Python session, the following line executes without error (as expected):
>>> import bugtest.foo.foo
However, the following line gives an error (not as expected):
>>> import bugtest.foo.foo as bar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'bugtest.foo.foo' has no attribute 'foo'
Note that this behavior is dependent on the folder foo and the file foo.py having the same base name. But is not dependent on actually trying to import bugtest.foo.foo. Trying to import bugtest.foo.baz will also fail as long as bugtest.foo.foo exists.
It is also dependent on the __init__.py files importing something from their respective submodules. |
|
Date |
User |
Action |
Args |
2017-09-07 19:11:59 | David Hagen | set | recipients:
+ David Hagen |
2017-09-07 19:11:59 | David Hagen | set | messageid: <1504811519.66.0.997643524015.issue31385@psf.upfronthosting.co.za> |
2017-09-07 19:11:59 | David Hagen | link | issue31385 messages |
2017-09-07 19:11:59 | David Hagen | create | |
|