[Python-Dev] Dropping __init__.py requirement for subpackages

Nick Coghlan ncoghlan at gmail.com
Thu Apr 27 12:43:51 CEST 2006


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. This should be a
> small change. I'm hesitant to propose *anything* new for Python 2.5,
> so I'm proposing it for 2.6; if Neal and Anthony think this would be
> okay to add to 2.5, they can do so.

I haven't scanned this whole thread yet, but my first thought was to just try 
to find a way to give a better error message if we find a candidate package 
directory, but there's no __init__.py file.

i.e. something like:

ImportError: __init__.py not found in directory '<whatever>/foo' for package 'foo'

I like the fact that __init__.py documents, right there in the file system 
directory listing, that the current directory is a Python package.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list