How to keep a module with the same name as a module it is importing from importing itself?
All: I am struggling with an import problem... 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? --PLB -- http://mail.python.org/mailman/listinfo/python-list
Handling import conflicts when module has the same name as a library module that it needs to import?
All: I am struggling with an import problem... In my package, myapp, there is a module called logging. This module, naturally, imports the standard library module logging. However, when I try 'import myapp.logging', the 'import logging' statement appears to be finding the myapp.logging module instead of the one in the standard library. How can I ensure that my logging module doesn't try to import itself? --PLB -- http://mail.python.org/mailman/listinfo/python-list
Handling import conflicts when module has the same name as a library module that it needs to import?
All: I am struggling with an import problem... In my package, myapp, there is a module called logging. This module, naturally, imports the standard library module logging. However, when I try 'import myapp.logging', the 'import logging' statement appears to be finding the myapp.logging module instead of the one in the standard library. How can I ensure that my logging module doesn't try to import itself? --PLB -- http://mail.python.org/mailman/listinfo/python-list
Re: How to keep a module with the same name as a module it is importing from importing itself?
Good call! The following snippet solved my problems portably.
path = sys.path[1:]
file, filename, description = imp.find_module('logging', path)
logging = imp.load_module('logging', file, filename, description)
Thanks!
--Peter
--
http://mail.python.org/mailman/listinfo/python-list
