importing a module when the module name is in a variable [duplicate]

You want the built in __import__ function

new_module = __import__(modulename)

Leave a Comment