[Tutor] __init__.py question

Válas Péter sulinet at postafiok.hu
Wed Jun 1 09:26:01 CEST 2011


I think it means that you may have a subdirectory named "string" in your
actual directory where you store e.g. your string-related scripts, and you
have a Python package named "string" _somewhere_else_, but in the module
search path. The subdirectory of the actual directory will have priority
bacause of its place, and will prevent you of importing the string package.

2011/6/1 Marilyn Davis <marilyn at 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.
>
> An example would probably set me straight.  Can anyone help with that?
>
> Marilyn Davis
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110601/cb9f1345/attachment.html>


More information about the Tutor mailing list