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

Phillip J. Eby pje at telecommunity.com
Thu Apr 27 01:59:30 CEST 2006

At 01:10 AM 4/27/2006 +0200, Thomas Wouters wrote:

>On 4/27/06, Guido van Rossum <<mailto:guido at python.org>guido at python.org> 
>>I'd worry that it'll cause complaints when the warning is incorrect
>>and a certain directory is being skipped intentionally. E.g. the
>>"string" directory that someone had. Getting a warning like this can
>>be just as upsetting to newbies!
>I don't think getting a spurious warning is as upsetting as getting no 
>warning but the damned thing just not working. At least you have something 
>to google for. And the warning includes the original line of source that 
>triggered it *and* the directory (or directories) it's complaining about, 
>which is quite a lot of helpful hints.

+1.  If the warning is off-base, you can rename the directory or suppress 
the warning.

As for the newbie situation, ISTM that this warning will generally come 
close enough in time to an environment change (new path entry, newly 
created conflicting directory) to be seen as informative.  The only time it 
might be confusing is if you had just added an "import foo" after having a 
"foo" directory sitting around for a while.

But even then, the warning is saying, "hey, it looked like you might have 
meant *this* foo directory...  if so, you're missing an __init__".  So, at 
that point I rename the directory...  or maybe add the __init__ and break 
my code.  So then I back it out and put up with the warning and complain to 
c.l.p, or maybe threaten Guido with a pitchfork if I work at Google.  Or 
maybe just a regular-sized fork, since the warning is just annoying.  :)

>Alrighty then. The list has about 12 hours to convince me (and you) that 
>it's a bad idea to generate that warning. I'll be asleep by the time the 
>trunk un-freezes, and I have a string of early meetings tomorrow. I'll get 
>to it somewhere in the afternoon :)

I like the patch in general, but may I suggest PackageWarning or maybe 
BrokenPackageWarning instead of ImportWarning as the class name?

More information about the Python-Dev mailing list