__init__.py 是导入包所必需的
is __init__.py essentially required for a package to be imported
from distutils import tests
这似乎没有引发任何错误,即使 distutils/tests 中没有 __init__.py。
我对这一点的理解是 __init__.py 本质上是导入包或子包所必需的
这显然在 Python 3.2 中发生了变化。在 setuptools documentation
我们发现:
Anyway, find_packages() walks the target directory, filtering by inclusion patterns, and finds Python packages (any directory). On Python 3.2 and earlier, packages are only recognized if they include an __init__.py file. Finally, exclusion patterns are applied to
但是,在 Python 3.6 documentation 中我们发现仍然需要 init.py 的声明。
我的理解是,当前行为接受 sys.path 上任何包含 .py 文件的目录。但是,我很难为此挖掘一些官方的东西。
from distutils import tests
这似乎没有引发任何错误,即使 distutils/tests 中没有 __init__.py。
我对这一点的理解是 __init__.py 本质上是导入包或子包所必需的
这显然在 Python 3.2 中发生了变化。在 setuptools documentation 我们发现:
Anyway, find_packages() walks the target directory, filtering by inclusion patterns, and finds Python packages (any directory). On Python 3.2 and earlier, packages are only recognized if they include an __init__.py file. Finally, exclusion patterns are applied to
但是,在 Python 3.6 documentation 中我们发现仍然需要 init.py 的声明。
我的理解是,当前行为接受 sys.path 上任何包含 .py 文件的目录。但是,我很难为此挖掘一些官方的东西。