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

Steven Bethard steven.bethard at gmail.com
Mon Mar 28 08:25:31 CEST 2005


Tian wrote:
> import ModuleA
> 
> classname = "Dog"
> module = globals()["ModuleA"]
> classobj = ???????           <---using classname
> instanct = classobj()

classobj = getattr(module, classname)

STeVe



More information about the Python-list mailing list