[issue34414] Absolute imports conflict with local files

Ronald Oussoren report at bugs.python.org
Thu Aug 16 12:55:56 EDT 2018


Ronald Oussoren <ronaldoussoren at mac.com> added the comment:

This is expected behaviour: When your run a script the directory containing the script is added to the start of sys.path. Running "python3.6 a/foo.py" therefore adds "a" to the start of sys.path, and "math.py" then shadows the stdlib module "math".

This has nothing to do with absolute imports. That is shown by "python3.6 -m foo.a". This runs the code in foo/a.py as module foo.a, and "math.py" is now only accessible as "foo.math" (it won't shadow the builtin module "math", even if you add "import math" to foo/a.py).

----------
resolution:  -> not a bug
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34414>
_______________________________________


More information about the Python-bugs-list mailing list