Importing dynamically loaded modules (in packages)?
Irmen de Jong
irmen at NOSPAMREMOVETHISxs4all.nl
Tue Apr 30 20:06:47 EDT 2002
Hello
I want to import a dynamically loaded module that comes from a package.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82234
more or less confirms the code that I've created myself (in Pyro).
But this code only works if the module does not come from a package.
i.e. loading the .py file of "TestModule" and then "import TestModule"
works fine, but loading "Package.TestModule.py" and then
"import Package.TestModule" doesn't work.
I've been toying around with creating package/modules structures
with new.module, mimicing the package structure on disk, but
even if I have this:
sys.modules['Package']= module 'Package'
module 'Package' . TestModule = the loaded module
"import Package.TestModule" still doesn't work: ""no module named TestModule""
How can I correct this?
Thank you!
Irmen de Jong
More information about the Python-list
mailing list