newbie question: how to get the class instance given a module object?

Tian wangtianthu at gmail.com
Mon Mar 28 07:56:54 CEST 2005


I have a module called ModuleA.py, in which there is a class called
Dog, what should I put in the "????" part to get the instance of class
Dog???



import ModuleA

classname = "Dog"
module = globals()["ModuleA"]
classobj = ???????           <---using classname
instanct = classobj()




More information about the Python-list mailing list