[Python-Dev] Dropping init.py requirement for subpackages (original) (raw)
M.-A. Lemburg mal at egenix.com
Wed Apr 26 21:10:10 CEST 2006
- Previous message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Next message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ! ::::
- Previous message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Next message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]