Creating instance

Syver Enstad syver-en+usenet at online.no
Wed Apr 2 00:40:04 CEST 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