Anonymous dynamic import
Christian Convey
christian.convey at gmail.com
Mon Aug 28 16:15:44 EDT 2006
Anyone know how to do this?:
I want a way to dynamically import modules (module names not known until
runtime). I want to end up with a handle to the resulting module object,
without having poluted my global module namespace in the process.
Basically I want to something like this:
def call_all_user_supplied_foo_functions(user_script_pathanmes):
for f in user_script_pathanmes:
a_module = magic_module_import_function(f)
a_module.foo()
Any ideas?
I've looked at using imp.load_source() or imp.load_module(), but it looks to
me like all of these polute the global namespace with the names of the
modules I'm importing.
Thanks,
Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060828/fa345fee/attachment.html>
More information about the Python-list
mailing list