For this directory hierarchy:
. βββ hello β βββ __init__.py β βββ world β βββ __init__.py βββ test.py
And the Python source files:
test.py:
if __name__ == '__main__': import hello
hi / __ __ INIT ru :.
import world
hello / world / __ __ INIT ru :.
print("yes you win")
Running test.py with Python 3.4 throws ImportError says the world module was not found, but everything is fine with Python 2.7.
I know that sys.path referenced when looking for imported modules, so adding a hello directory to sys.path fixes the error.
But in Python 2.7, before the world import, the hello directory is also not in sys.path . What causes this difference? Is there any recursive search policy in Python 2.7?
source share