Function decorator having arguments is complicated

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed Apr 29 05:22:18 EDT 2015


> On Monday 27 April 2015 12:37, Makoto Kuwata wrote:
> 
>>  def multiply(n):
>>    def deco(func):
>>      def newfunc(*args, **kwargs):
>>        return n * func(*args, **kwargs)
>>      return newfunc
>>    return deco

I'd like to be able to write that as

    def multiply(n)(func)(*args, **kwargs):
       return n * func(*args, **kwargs)

-- 
Greg



More information about the Python-list mailing list