New submission from Anthony Sottile: PEP420 makes __init__.py files optional: https://docs.python.org/3/whatsnew/3.3.html#pep-420-implicit-namespace-packages
Though it seems without them, pkgutil.walk_packages does not function as desired: https://docs.python.org/3/library/pkgutil.html#pkgutil.walk_packages Consider the following example: ``` $ tree foo foo ├── bar │ ├── baz.py │ └── __init__.py ├── __init__.py └── womp.py ``` And a test script # test.py ``` import pkgutil import foo for _, mod, _ in pkgutil.walk_packages(foo.__path__, foo.__name__ + '.'): print(mod) ``` In both python2 and python3 I get the following output: ``` $ python2.7 test.py foo.bar foo.bar.baz foo.womp $ python3.5 test.py foo.bar foo.bar.baz foo.womp ``` Removing the __init__.py files and only using python3, I get this: ``` $ find -name '__init__.*' -delete $ python3.5 test.py foo.bar ``` The modules are definitely importable: ``` $ python3.5 -c 'import foo.bar.baz' $ ``` Originally asked as a question on stackoverflow: http://stackoverflow.com/questions/41203765/init-py-required-for-pkgutil-walk-packages-in-python3 ---------- components: Library (Lib) messages: 285361 nosy: Anthony Sottile priority: normal severity: normal status: open title: __init__.py required for pkgutil.walk_packages in python3 type: behavior versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29258> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com