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

Guido van Rossum guido at python.org
Thu Apr 27 01:24:19 CEST 2006


On 4/26/06, Thomas Wouters <thomas at python.org> wrote:
> Of course, I only consider *my* reasons to be valid, and mine weren't
> knee-jerk or tool-related. I don't think Python should be going "Oh, what
> you wanted wasn't possible, but I think I know what you wanted, let me do it
> for you", first of all because it's not very Pythonic, and second of all
> because it doesn't lower the learning curve, it just delays some upward
> motion a little (meaning the curve may become steeper, later.) A clear
> warning, on the other hand, can be a helpful nudge towards the 'a-HA'
> moment.

That still sounds like old-timer reasoning. Long ago we were very
close to defining a package as "a directory" -- with none of this
"must contain __init__.py or another *.py file" nonsense. IIRC the
decision to make __init__.py mandatory faced opposition too, since
people were already doing packages with just directories (which is
quite clean and elegant, and that's also how it was in Java), but I
added it after seeing a few newbies tear out their hair.

I believe that if at that time __init__.py had remained optional, and
today I had proposed to require it, the change would have been derided
as unpythonic as well. There's nothing particularly unpythonic about
optional behavior; e.g. classes may or may not provide an __init__
method.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list