You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python 3.11.9 (main, Jan 1 1980, 00:00:00) [Clang 16.0.6 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import a.b as b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'a.b'
>>> import a.c as c
>>> c
'c'
>>> import a.d as d
>>> d
<module 'a.d' from '/the/path/to/Python-3.11.9/a/d.py'>
I think for b and d, it works correctly because b is not a module and d is. But for c, I expect it to be a module, but it is actually a variable.
I am not familiar to python but I cannot find any info about this behavior, so I ask it here.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered:
This was discussed recently in #117860. It is not obvious that this is a bug. The code in __init__.py sets c to 'c'. import a.c as c is equivalent to import a.c; c = a.c.
To avoid confusion try to not override the names which correspond to names of submodules with other values.
Bug report
Bug description:
File structure:
File content:
Run in python:
I think for b and d, it works correctly because b is not a module and d is. But for c, I expect it to be a module, but it is actually a variable.
I am not familiar to python but I cannot find any info about this behavior, so I ask it here.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: