开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜