[issue33547] Relative imports do not replace local variables
Rolf Campbell
report at bugs.python.org
Fri May 18 15:30:32 EDT 2018
Rolf Campbell <thats.unpossible at gmail.com> added the comment:
Re-opening because I've found a simple example that does not involve __main__.
./func/__init__.py:func = 1
./func/__init__.py:from . import func
./func/__init__.py:print(f"Namespace value of func after func module import:{func}")
./func/func.py:print("Module imported")
./main.py:import func
./main.py:def func(x):
./main.py: return x
If you create files that look like that, and then run: "python3.6 main.py" I get this output:
Namespace value of func after func module import:1
If I comment out the "func = 1" line, then func ends up being imported (and printing as a <module...>).
----------
status: closed -> open
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33547>
_______________________________________
More information about the Python-bugs-list
mailing list