Possible Duplicate:
How does one do the equivalent of “import * from module” with Python's import function?
I'm trying to dynamically load a python module into the current module using a string for the name of the module. The command I'm trying to emulate is
from modulename import *
except using a string variable instead of "modulename". I'm having trouble understanding the python docs on import, but I see that if I do
_temp = __import__(modulename, globals(), locals(), [], -1)
this is functionally equivalent to
import modulename as _temp
which is close to what I want. But I want everything loaded into the current module's namespace. I'm hoping there's another way to call __import__
to accomplish this?