[mod_python] mod_python imports foo/__init__.py, not foo/bar.py

Graham Dumpleton grahamd at dscpl.com.au
Sat Oct 15 20:12:47 EDT 2005


See:

   http://www.python.org/doc/essays/packages.html

Specifically:

   What If I Have a Module and a Package With The Same Name?

   You may have a directory (on sys.path) which has both a module spam.py
   and a subdirectory spam that contains an __init__.py (without the
   __init__.py, a directory is not recognized as a package). In this 
case,
   the subdirectory has precedence, and importing spam will ignore the
   spam.py file, loading the package spam instead. If you want the module
   spam.py to have precedence, it must be placed in a directory that 
comes
   earlier in sys.path.

Graham

On 16/10/2005, at 10:03 AM, Fabiano Sidler wrote:

> Hi folks!
>
> When I try importing a module 'foo.bar', mod_python imports 
> foo.__init__.py
> instead of foo.bar! Why so?
> Forgive me, if you think this is a silly question, but with Google I 
> only
> found unhelpful results.
>
> Thanks,
> fips
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list