[issue41042] import searches for package even after file was found successfully
Eric V. Smith
report at bugs.python.org
Fri Jun 19 19:37:50 EDT 2020
Eric V. Smith <eric at trueblade.com> added the comment:
You should just be using "import index". By using "import index.py", you're telling the interpreter to first import index, execute the code in it, then look for a sub-module named "py" (full name: index.py). Since no such sub-module exists, and index is not a package, you get the exception you're seeing.
It's like "import os.path": first import "os", then look for "path" inside of that.
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41042>
_______________________________________
More information about the Python-bugs-list
mailing list