From: Michele Simionato on 28 Mar 2010 10:17 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)
From: Patrick Maupin on 28 Mar 2010 12:26 On Mar 28, 9:17 am, Michele Simionato <michele.simion...(a)gmail.com> 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(5, 7) That looks cool (and I'm glad you mentioned it), but it appeared to me the OP was trying to manually construct the equivalent of a decorator without the "@" syntax, in order to gain an understanding of how decorators work, and for this particular purpose, piling additional magic on top of decorators is probably not helpful :-) Regards, Pat
First
|
Prev
|
Pages: 1 2 Prev: Call for papers (Deadline Extended): SETP-10, USA, July 2010 Next: Ipython(x,y) Won't Run |