Calling constructor of unknown classes

Lars Heuer python at quixs.com
Sat May 8 09:35:34 EDT 2004


Hi John,

> Since you know the module (you just imported it), do something
> like this:

> klas = getattr(mod, "className")

> instance = klas()

Thanks. I tried something similar, but instead of my way, your way works. ;)

Best regards,
Lars





More information about the Python-list mailing list