Why is __init__.py not being called?

I am using Python 2.7 and have the following files:

./__init__.py ./aoeu.py 

__init__.py has the following content:

 aoeu aoeuaoeu aoeuaoeuaoeu 

so I would expect to run aoeu.py for an error when Python tries to load __init__.py , but that is not the case. The behavior is the same if PYTHONPATH is set to '.' or unset.

What's happening?

+6
source share
1 answer

__init__.py makes the environment directory a package. It will not be executed unless you actually try to import the package directly.

+14
source

Source: https://habr.com/ru/post/897924/


All Articles