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

Joe Smith unknown_kev_cat at hotmail.com
Wed Apr 26 22:33:06 CEST 2006


"Guido van Rossum" <guido at python.org> wrote in message 
news:ca471dc20604261016g14854274i970d6f4fc72561c7 at mail.gmail.com...
> (Context: There's a large crowd with pitchforks and other sharp pointy
> farm implements just outside the door of my office at Google. They are
> making an unbelievable racket. It appears they are Google engineers
> who have been bitten by a misfeature of Python, and they won't let me
> go home before I have posted this message.)
>
> One particular egregious problem is that *subpackage* are subject to
> the same rule. It so happens that there is essentially only one
> top-level package in the Google code base, and it already has an
> __init__.py file. But developers create new subpackages at a
> frightening rate, and forgetting to do "touch __init__.py" has caused
> many hours of lost work, not to mention injuries due to heads banging
> against walls.
>

It seems to me that the right way to fix this is to simply make a small 
change to the error message.
On a failed import, have the code check if there is a directory that would 
have been  the requested package if
it had contained an __init__ module. If there is then append a message like 
"You might be missing an __init__.py file".

It might also be good to check that the directory actually contained python 
modules.





More information about the Python-Dev mailing list