Q: Why is __init__.py required

G. David Kuhlman dkuhlman at netcom.com
Sun Aug 1 23:33:14 CEST 1999


I have looked and looked for this.  Whenever I put an empty
__init__.py in a package, I ask myself why I have to do this.  I
read Guido's article on packages and it told me that I have to put
an __init__.py in a directory in order for the directory to be
recognized as a package.  But it doesn't say why.

I'm not asking for this behavior to be changed.  I like it the way
it is.  I just want to know *why* it has to be that way.  In what
way would the Python interpreter get confused if it didn't have
__init__.py to distinguish package directories from non-package
directories?

I've looked in the standard 1.5.2 docs and the FAQ and in Guido's
package essage and have searched Deja Vue.

Can anyone point me to an explanation?

It bugs me when I don't know why.  My parents used to have to
explain things to me like why I couldn't jump off the roof of the
house.

Thanks in advance for help.  

  - Dave




More information about the Python-list mailing list