[Tutor] Should a "data" directory have a __init__.py file?

Oscar Benjamin oscar.j.benjamin at gmail.com
Mon Jan 18 06:03:36 EST 2016


On 18 January 2016 at 04:27, Ben Finney <ben+python at benfinney.id.au> wrote:
>
> The module import system will only recognise a directory as a “package”
> (Python's technical term for “a point in the import hierarchy which
> contains other things to import”) if that directory contains a file
> named ‘__init__.py’. If you do not need the directory to also be
> recognised as a package, it should not have such a file.

That was the case prior to 3.3. However (I can't immediately test this
but) now a directory without an __init__.py can be an implicit
namespace package if it contains importable modules:

https://www.python.org/dev/peps/pep-0420/

--
Oscar


More information about the Tutor mailing list