function decorator-like function

Patrick Maupin pmaupin at
Sun Mar 28 18:26:39 CEST 2010

On Mar 28, 9:17 am, Michele Simionato <michele.simion... at>
> Another option is to use my own decorator module (http://
> 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 :-)


More information about the Python-list mailing list