dynamic class instantiation

Ognen Duzlevski maketo at ukato.freeshell.org
Tue Jan 31 07:01:17 EST 2006


Kent Johnson <kent at kentsjohnson.com> wrote:
> Ognen Duzlevski wrote:
> > Say I got "page" as a string. How do I go about 
> > instantiating a class from this piece of information? To make it 
> > more obvious how do I create the page() class based on the "page" 
> > string I have? 

> Use getattr().

Hi Kent, this is exactly what I was looking for. I can't believe I didn't think
of getattr() myself! ;(

Cheers,
Ognen



More information about the Python-list mailing list