Adding bound methods dynamically... CORRECTED

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Sep 1 23:09:12 CEST 2005


Kevin Little a écrit :

Oops, sorry, forgot to answer

> '''
> I want to dynamically add or replace bound methods in a class. 
(snip)
> Is there a more pythonic way that's as straight forward?

What's wrong with:

class Foo:
   pass

def method(self):
   print "%s" % self

f = Foo()
Foo.method = method
f.method()



More information about the Python-list mailing list