importing module through variable

André Dahlqvist andre at beta.telenordia.se
Tue Jun 13 10:51:25 EDT 2000


Hi

I have a variable which is assigned the name of a module. Is it possible
to use this variable in an import statement? Someone told me I could use
"exec("import %s" %var) and while this works I am not sure how I can
access the module by it's name after that. Using something like 
var.modfunc() won't do it since 'var' is just a string containing the 
modules name.

// André



More information about the Python-list mailing list