[Python-Dev] Dropping __init__.py requirement for subpackages
Clark C. Evans
cce at clarkevans.com
Tue Jun 20 16:36:21 CEST 2006
+1 Excellent Change
+1 Minimal Backward Compatibility Difficulties
I think this would also help quite a bit with newbie adoption of Python.
I've had to explain this un-feature on numerous occassions and it given
how smart Python is, I've wondered why it has this requirement. If you
look in various open source packages, you'll find that 95% of these
__init__.py files are empty. The ones at my work actually say:
# stupid Python requirement, don't remove this file
Why? Someone decided to remove files of length 0 in our repository
without realizing the consequences. Since it had the __init__.pyc file
around, it still worked... till one brought down a fresh copy of the
repository and then it just "stopped" working. Quite a bit of hair
pulling that one caused us.
The only case where this might cause a problem is with "resource"
directories that only contain ".html", ".jpg" and other files. So,
perhpas this feature would only turn a directory into a package if
it didn't have any .py files. It could also trigger only when the
package is explicitly imported?
Good luck /w the pitch-fork wielding users and telling the old-timers
where they can keep their backward compatibility.
More information about the Python-Dev