2011/5/31 Marilyn Davis <mari...@pythontrainer.com>:
> I don't really understand why __init__.py is necessary -- except that it
> makes the packaging scheme work.
>
> The Python Manual by Guido van Rossum and Fred L. Drake says:
>
> ... this is done to prevent directories with a common name, such as
> string, from unintentionally hiding valid modules that occur later on in
> the module search path.

I think it is just to avoids unexpected conflicting namespaces that
could happen by accidentally importing non-Python directories. By
explicitly putting a __init__.py module in your directory, you are
telling Python you want your directory to be considered as a Python
package and to be imported in your namespace. If you have a
conflicting namespace, it means you explicitly wanted this to happen,
then you have to deal with it (or fix it if unintended).

-- 
Alex | twitter.com/alexconrad
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to