How to import a module based on an argument
Mark McEahern
marklists at mceahern.com
Thu Mar 25 15:53:06 EST 2004
Sean Berry wrote:
>I don't know that this partilarily bad programming,
>but I was interested in doing the following.
>
>def functionname( module, var1, var2 ):
> import module
>
>I would like to be able to pass the module name
>as an argument and have the module imported as a result.
>
>For instance... functionname( os, "1", 234)
>
>Thanks for any help.
>
>
Checkout __import__.
// m
More information about the Python-list
mailing list