Small problem when overloading member functions...
bdesth at nospam.free.fr
Thu Jan 9 05:51:22 CET 2003
> What you're doing here is 'replacing' an instance method with another
> one (I guess in Python's parlance, we should say 'rebinding').
> If what you're trying to do is just that (replacing an instance method),
> do it the simplest way (the one that is not commented in your code).
> Now if you want to 'replace' a method for all existing instances of a
> class, I leave it up to some __class__ Guru !-)
Ok, I got it a few minutes later :
print "old test"
a = Truc()
print "new test"
a.__class__.test = test2
More information about the Python-list