Why python load my module from directory, even if the directory shouldn't be treated as a package (doesn't contains __init__.py)?
app
main.py
fake_module
module.py
this works, even if fake_module doesn't contains __init__.py
import fake_module.module
If i would create regular fake_module with __init__.py and module.py file somewhere in sys.path, will be module.py loaded from this regular fake_module package?
I am using pycharm and python3.3
asked Jun 15, 2013 at 16:32
Krab
6,8066 gold badges47 silver badges83 bronze badges
1 Answer 1
It looks like the __init__.py is optional as of Python 3.3. See also PEP420.
answered Jun 15, 2013 at 16:45
Aya
42.5k6 gold badges60 silver badges56 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Martijn Pieters
Bingo, I forgot about the new implicit namespaces support in 3.3.
lang-py
print fake_module.module.__file__give you?print fake_module.__file__prints what?print type(fake_module)give?