Classic vs New-style classes...

Martin Chilvers martin_chilvers at gmx.net
Sat Jun 21 05:26:54 CEST 2003


> On Fri, Jun 20, 2003 at 09:35:45PM -0500, Martin Chilvers wrote:
> > 
> > What I really wanted was this:-
> > 
> > 	def addToClass(klass, name, value):
> >     	    exec('klass.%s = value' % name)
> 
> What you *really* wanted was:
> 
>     setattr(klass, name, value)
> 
> Which works just fine on new- and old-style classes.

Doh!

;^)

Martin







More information about the Python-list mailing list