New submission from Marko Nervo <ma...@python.it>: 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) return (lambda *x, **y: curry(func, *(args + x), **dict(kwargs, **y))) This function allows you to create curried functions or methods in two main ways: (1) >>> def adder(x, y, z): ... return (x + y + z) >>> adder = curry(adder) (2) >>> @curry ... def adder(x, y, z): ... return (x + y + z) Curried functions could be used as follow. >>> adder(2, 3, 4) >>> adder(2, 3)(4) >>> adder(2)(3)(4) >>> adder(z = 4)(2, 3) # etc, etc, etc... Best regards, Marco. ---------- components: Library (Lib) messages: 147882 nosy: collinwinter, eric.araujo, gregory_p, markonervo, rhettinger, serprex priority: normal severity: normal status: open title: Add a curry function to the functools module type: feature request versions: Python 2.7, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13430> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com