I am trying to write a currying decorator in python, and I think I\'ve got the general idea down, but still got some cases that aren\'t working right...
def
The solution from Roger Christman will not work with every constellation. I applied a small fix to also handle this situation:
curried_func(1)(2,3)
The small fix that makes it work with every constellation lies in the returned lambda:
def curried(func):
def curry(*args):
if len(args) == func.__code__.co_argcount:
ans = func(*args)
return ans
else:
return lambda *x: curry(*(args+x))
return curry