Creating instance

Syver Enstad syver-en+usenet at online.no
Tue Apr 1 17:40:04 EST 2003


Salvatore <salvatore at wanadoo.fr> writes:

> Hello,
> 
> I would like to create an instance of class
> from the string name of the class
> 
> class Foo:
> 	pass
> 
> classname = 'Foo'

Does this suit you?
 
instance = eval(classname)()

-- 

Vennlig hilsen 

Syver Enstad




More information about the Python-list mailing list