Re: help with flexible decorators

2007-08-07 Thread Bruno Desthuilliers
james_027 a écrit : > Hi, > > I want to write a flexible decorators to edit a function that may have > 1 or more arguments... > > def enhance(func): > def new(x): > #do something ... > return func(x) > return new > > @enhance > def method_a(x): > #do something ... >

Re: help with flexible decorators

2007-08-06 Thread Lawrence Oluyede
james_027 <[EMAIL PROTECTED]> wrote: > While the enhance decorator work with functions of 1 argument, how do > I make it to work with more than one arguments. Using *args. Something like this: def enhance(f): def _new(*args): return f(*args) + 1 return _new @enhance def f(*args):

help with flexible decorators

2007-08-06 Thread james_027
Hi, I want to write a flexible decorators to edit a function that may have 1 or more arguments... def enhance(func): def new(x): #do something ... return func(x) return new @enhance def method_a(x): #do something ... While the enhance decorator work with functions of