[Python-ideas] @return?

Daniel Stutzbach daniel at stutzbachenterprises.com
Wed Apr 14 02:32:48 CEST 2010


On Tue, Apr 13, 2010 at 7:23 PM, Conrad Irwin
<conrad.irwin at googlemail.com>wrote:

> > import decorator
> > def my_decorator(func):
> >     return decorator.decorator(func, lambda: func(modulate(args)))
>
> Of course, everything is more succinct when a lambda can be used instead
> of defining a new function; my proposal was to deal with the times when
> this shorthand is not available.
>

Actually, I wasn't thinking clearly earlier.  The correct code would be
simply:

@decorator.decorator
def my_decorator(func, *args, **kw):
    return func(modulate(args))

No lamba is needed, and you can make the inside of the wrapper as
complicated as you wish.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100413/98b5e7cf/attachment.html>


More information about the Python-ideas mailing list