Duncan Booth wrote:
> Matias Surdi <[EMAIL PROTECTED]> wrote:
>> setattr(a,"a",new.instancemethod(replace_method(a.a) ,a,A))
>
> a.__dict__['a'] = new.instancemethod(replace_method(a.a),a,A)
Or even
a.a = new.instancemethod(...)
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Matias Surdi wrote:
> I have the following code:
>
> --
> import new
>
> class A:
> def a(self):
> print "Original"
>
> def other(cad):
> return cad + " modified"
>
> def replace_method(method):
> def b(self,*args,**kwargs):
> result = m
Matias Surdi <[EMAIL PROTECTED]> wrote:
> I have the following code:
>
> --
> import new
>
> class A:
> def a(self):
> print "Original"
>
> def other(cad):
> return cad + " modified"
>
> def replace_method(method):
> def b(self,*args,**kwargs):
>
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
I have the following code:
--
import new
class A:
def a(self):
print "Original"
def other(cad):
return cad + " modified"
def replace_method(method):
def b(self,*args,**kwargs):
result = method(*args,**kwargs)
return other(result)