[Python-Dev] Decorators with arguments are curries!

Nick Coghlan ncoghlan at iinet.net.au
Wed Aug 11 07:47:20 CEST 2004


Phillip J. Eby wrote:
> At 10:36 PM 8/7/04 +1000, Andrew Durdin wrote:
> 
>> def bar_decorator(func, param):
>>     print param
>>     return func
>>
> Decorator syntax does *not* provide currying.  You have to write 
> something like this:
> 
Or, if the 'partial' function is in the standard lib by that point, you
can use it to get your decorator. . .

X>>> @partial(bar_decorator(param_val))
X... def myFoo(): pass

Cheers,
Nick.

(P.S. Does the interactive interpreter currently do a line continuation
after the decorator line?)

-- 
Nick Coghlan               |  Eugene, Oregon
Email: ncoghlan at email.com  |             USA






More information about the Python-Dev mailing list