Re: Wrapping a method twice

2008-06-25 Thread Michele Simionato
On Jun 25, 1:52 pm, [EMAIL PROTECTED] wrote: >Try: > > def append(method,bottom): >     def wrapped(*args, **kwargs): >         res = method(*args, **kwargs) >         return bottom(res,*args, **kwargs) >     wrapped.__name__ = method.__name__ >     setattr(method.im_class,method.__name__,wrapped)

Re: Wrapping a method twice

2008-06-25 Thread marek . rocki
Nicolas Girard napisał(a): > prepend(C.f,pre) This wraps f, returns wrapped and binds it to C.f (but the method.__name__ is still wrapped). > append(C.f,post) This wraps wrapped (the one previously returned), returns wrapped (a new one) and binds it to C.wrapped (since that is what its meth

Wrapping a method twice

2008-06-25 Thread Nicolas Girard
Hi all, given the following code: --- def append(method,bottom): def wrapped(*args, **kwargs): res = method(*args, **kwargs) return bottom(res,*args, **kwargs) setattr(method.im_class,method.__name__,wrapped) def prepend(method,top): def wrapped(*args, **kwargs):