[Python-Dev] Dropping init.py requirement for subpackages (original) (raw)

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