[Python-Dev] Keeping __init__.py empty for Python packages used for module grouping.

Brett Cannon brett at python.org
Tue Jan 25 00:09:01 CET 2011


On Mon, Jan 24, 2011 at 11:18, Georg Brandl <g.brandl at gmx.net> wrote:
> Am 24.01.2011 20:04, schrieb Raymond Hettinger:
>> Looking at http://docs.python.org/dev/library/html.html#module-html it would
>> appear that we've created a new module with a single trivial function.
>>
>> In reality, there was already a python package, html, that served to group
>> two loosely related modules, html.parser and html.entities.
>>
>> ISTM, that if we're going to use python packages as "namespace containers"
>> for categorizing modules, then the top level __init__ namespace should be
>> left empty.
>>
>> Before the placement of html.escape() becomes set in stone, I think we should
>> consider putting it somewhere else.
>
> To be honest, I don't see the issue.  I don't see stdlib packages as
> "namespace containers", but rather as a nice way of structuring functionality.
> And remember that flat is better than nested -- why should escape() be put
> away into a new submodule?

Importlib also acts as a precedent with importlib.import_module(). I
honestly don't feel the need to treat packages as a namespace
explicitly (but then again I also disagree with the argument that
__init__.py needs to be left empty).


More information about the Python-Dev mailing list