Why is __init__.py not being called?
I'm using Python 2.7 and have the following fil开发者_StackOverflowes:
./__init__.py
./aoeu.py
__init__.py
has the following contents:
aoeu aoeuaoeu aoeuaoeuaoeu
so I would expect running aoeu.py to error when Python tries to load __init__.py
, but it doesn't. The behavior is the same whether PYTHONPATH is set to '.' or unset.
What's going on?
__init__.py
makes the enclosing directory a package. It won't be executed unless you actually try to import the package directly.
精彩评论