getting class information from module name
pyth at devel.trillke.net
Tue Aug 20 21:47:55 CEST 2002
> I would like to instantiate instances of all the classes that I have
> defined in a module. I know the module name, how do I go about with
> the instantiation part?
you could do something like:
instances = 
for modobject in somemodule.__dict__.values():
instances.append(modobject()) # note the constructor call
but this probably only works for special modules as some classes
require some other objects to be instantiated.
More information about the Python-list