On Dec 21, 11:28 am, Matias Surdi <[EMAIL PROTECTED]> wrote: > I have the following code: [...] > As you can see, what I'm trying to do is "replace" a method with another > one wich is the same method but with a function applied to it (in this > case, a string concatenation ( +" modified")) > > Can anybody help me with this?
Why not use inheritance? class A(object): def a(self): print "Original" class B(A): def a(self): super(B, self).a() print 'modified' a = B() a.a() I'm not saying the code below is a good idea, but it solves the problem of post-hoc modification a = A() a.__class__ = B a.a() we could probably come up with a better solution if we knew more about the problem you were trying to solve... -- bjorn -- http://mail.python.org/mailman/listinfo/python-list