Possible to import a module whose name is contained in a variable?

Steven Reddie smr at essemer.com.au
Mon Mar 7 00:34:08 EST 2005


Hi,

I want to do something like the following, which doesn't work:

    modulename = 'module'
    import modulename

The error is that there is no module named 'modulename'.  Is there a
way to get that variable expanded?

Regards,

Steven



More information about the Python-list mailing list