import modules at runtime

Manus Hand mjhand at concentric.net
Mon May 8 15:34:55 EDT 2000


I regularly do the following, after dynamically realizing that "object"
should be an instance of a particular "className" found in a certain
"moduleName":

code = __import__(moduleName)
object = code.__dict__[className](initParam1, initParam2, etc.)

Works like a charm.

Manus





More information about the Python-list mailing list