How to keep a module with the same name as a module it is importing from importing itself?
Laszlo Zsolt Nagy
gandalf at geochemsource.com
Tue Feb 8 08:23:03 EST 2005
>In my package, myapp, I have a module, logging.py. That module,
>naturally, imports the library module logging with an 'import logging'
>statement. However, when I use 'import myapp.logging' in my script,
>the myapp.logging module tries to import itself rather than the library
>logging module.
>
>How can I prevent this from happening other than using a name that
>doesn't conflict?
>
>
Did you try the built-in 'imp' module?
http://docs.python.org/lib/module-imp.html
I believe that 'load_module' is your very best friend. :-)
Another idea: rename your modules so they do not conflict with standard
modules.
Best,
Laci 2.0
--
_________________________________________________________________
Laszlo Nagy web: http://designasign.biz
IT Consultant mail: gandalf at geochemsource.com
Python forever!
More information about the Python-list
mailing list