Importing to

J

James Stroud

Many thanks to the numerous helpful comments by Paul Rubin, Carsten
Haese and others in the thread "How to pass a reference to the current
module".

After digesting these comments, I came up with this way to circumvent
the problem of attempting to reference modules that import other modules
in said imported modules (executed in main):


# branches ==> dictionary of dictionaries (actually a ConfigObj)
for (name, branch) in branches.items():
modname = branch.get('__module__', None)
if modname is None:
namespace = globals()
else:
namespace = __import__(modname).globals()
fname = branch.get('__function__', name)
function = namespace[fname]
# etc.


I'm wondering if this approach seems problematic to anyone.

Thanks again for all of the help I've received.

James


--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top