Re: function decorator-like function

2010-03-28 Thread Patrick Maupin
On Mar 28, 9:17 am, Michele Simionato wrote: > Another option is to use my own decorator module (http:// > pypi.python.org/pypi/decorator): > > from decorator import decorator > > @decorator > def d(func, *args): >     print 3 >     return func(*args) > > @d > def f(a, b): >     print a + b > > f(

Re: function decorator-like function

2010-03-28 Thread Michele Simionato
Another option is to use my own decorator module (http:// pypi.python.org/pypi/decorator): from decorator import decorator @decorator def d(func, *args): print 3 return func(*args) @d def f(a, b): print a + b f(5, 7) -- http://mail.python.org/mailman/listinfo/python-list

Re: function decorator-like function

2010-03-27 Thread Patrick Maupin
On Mar 27, 11:24 am, vsoler wrote: > I see what happened. The first line was somehow hidden. > Thank you very much. You're welcome. Sorry about the formatting. Also, note that if your decorator is complicated, you might want to use a class instead of a nested function. Here's the same thing, u

Re: function decorator-like function

2010-03-27 Thread vsoler
On 27 mar, 17:21, vsoler wrote: > On 27 mar, 17:06, Patrick Maupin wrote: > > > > > On Mar 27, 10:24 am, vsoler wrote: > > > > Hi, > > > > Still learning Python, now decorators. > > > > Before diving deeply into decorators, I'd like to apply a function to > > > another function. > > > > My "extr

Re: function decorator-like function

2010-03-27 Thread vsoler
On 27 mar, 17:06, Patrick Maupin wrote: > On Mar 27, 10:24 am, vsoler wrote: > > > > > Hi, > > > Still learning Python, now decorators. > > > Before diving deeply into decorators, I'd like to apply a function to > > another function. > > > My "extremely simple function" should print number 3, the

Re: function decorator-like function

2010-03-27 Thread Patrick Maupin
On Mar 27, 10:24 am, vsoler wrote: > Hi, > > Still learning Python, now decorators. > > Before diving deeply into decorators, I'd like to apply a function to > another function. > > My "extremely simple function" should print number 3, then the sum of > its 2 arguments. > > Say that I call   f(5,7

function decorator-like function

2010-03-27 Thread vsoler
Hi, Still learning Python, now decorators. Before diving deeply into decorators, I'd like to apply a function to another function. My "extremely simple function" should print number 3, then the sum of its 2 arguments. Say that I call f(5,7) I'd like to get, somehow, 3 then 12. I've tried the