import with variable

Rene Pijlman reply.in at the.newsgroup
Mon Mar 17 12:15:12 CET 2003


Marcio R. da Silva:
>I'm trying to import a file using the name stored in a variable. For example:
>
>  r = "module"
>  import r
>
>I know this didn't work, but I would like to know how I can do this. I
>need to create a module "on the fly" and use it in my program.

See __import__ on
http://www.python.org/doc/current/lib/built-in-funcs.html

-- 
René Pijlman




More information about the Python-list mailing list