Function to import module to namespace

bvdp bob at mellowood.ca
Sun Jun 29 15:08:36 EDT 2008


Is it possible to do this from a function: import a module and append 
the defs in that module to an existing module/namesapce.

So, in my code I have something like:

# main code
import mods

def loadmore(n):
    import_module(n, mods)

....
# end of main

this will permit the addition of the the stuff in file 'n.py' to 'mods'.

Assuming that foo1() is defined in newmod, I should now be able to do 
something like mods.foo1().

Thanks.





More information about the Python-list mailing list