Creating Classes Dynamically?

Christian Tismer tismer at tismer.com
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 appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com




More information about the Python-list mailing list