[issue13430] Add a curry function to the functools module

2011-11-18 Thread Marko Nervo
Marko Nervo added the comment: > You will have to try a bit > harder and showcase examples of *useful* code that are made > significantly easier through the use of curry(). Curry is a more advanced functools.partial. So, it could be used *at least* as partial, but it is more powerful

[issue13430] Add a curry function to the functools module

2011-11-18 Thread Marko Nervo
Marko Nervo added the comment: > But so does functools.partial. So the question is, what use case does it > help that functools.partial doesn't? Sure, it's common `defining new functions on other functions`... more times. Here a stupid example with fold (our reduce).

[issue13430] Add a curry function to the functools module

2011-11-18 Thread Marko Nervo
Marko Nervo added the comment: I totally disagree with the syntax for curried function, but I think a curry function is perfect for the functools module and I also think it could be useful at least as functools.partial. In addition, a lot of languages support currying, such as Haskell, Scala

[issue13430] Add a curry function to the functools module

2011-11-18 Thread Marko Nervo
Marko Nervo added the comment: In [1]: import functools In [2]: def adder(x, y, z): ...: return (x + y + z) ...: In [3]: adder = functools.partial(adder) In [4]: adder(2)(3)(4) --- TypeError

[issue13430] Add a curry function to the functools module

2011-11-18 Thread Marko Nervo
New submission from Marko Nervo : I think it would be very usefull to add a curry function to the functools module. It should be like this. def curry(func, *args, **kwargs): if (len(args) + len(kwargs)) >= func.__code__.co_argcount: return func(*args, **kwargs) ret