[Python-Dev] Dropping __init__.py requirement for subpackages
M.-A. Lemburg
mal at egenix.com
Wed Apr 26 21:10:10 CEST 2006
Guido van Rossum wrote:
> On 4/26/06, Phillip J. Eby <pje at telecommunity.com> wrote:
>> At 10:16 AM 4/26/2006 -0700, Guido van Rossum wrote:
>>> So I have a very simple proposal: keep the __init__.py requirement for
>>> top-level pacakages, but drop it for subpackages.
>> Note that many tools exist which have grown to rely on the presence of
>> __init__ modules. Also, although your proposal would allow imports to work
>> reasonably well, tools that are actively looking for packages would need to
>> have some way to distinguish package directories from others.
>>
>> My counter-proposal: to be considered a package, a directory must contain
>> at least one module (which of course can be __init__). This allows the "is
>> it a package?" question to be answered with only one directory read, as is
>> the case now. Think of it also as a nudge in favor of "flat is better than
>> nested".
>
> I'm not sure what you mean by "one directory read". You'd have to list
> the entire directory, which may require reading more than one block if
> the directory is large.
Sounds like a lot of filesystem activity to me :-)
Currently, __init__.py is used as landmark by the import code
to easily determine whether a directory is a package using
two simple I/O operations (fstat on __init__.py, __init__.py[co]).
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Apr 26 2006)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Python-Dev
mailing list