Re: Instrospection question

2007-12-21 Thread Peter Otten
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

Re: Instrospection question

2007-12-21 Thread Peter Otten
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

Re: Instrospection question

2007-12-21 Thread Duncan Booth
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): >

Re: Instrospection question

2007-12-21 Thread thebjorn
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

Instrospection question

2007-12-21 Thread Matias Surdi
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)