Creating Classes Dynamically?

Christian Tismer tismer at
Thu Apr 20 19:03:12 CEST 2000

Jerome Chan wrote:
> Is there a way to create an object of a class from a string?

Yes, you can use exec on the string if it evaluates as a call
to the class.
If you don't want to use exec, you also have the option to use the
new module. Import it and read the doc strings.

ciao - chris

Christian Tismer             :^)   <mailto:tismer at>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship*
14163 Berlin                 :     PGP key ->
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?

More information about the Python-list mailing list