Scott David Daniels Scott.Daniels at Acm.Org
Mon Jul 28 01:24:38 CEST 2003

Diez B. Roggisch wrote:
> Ah, ok. That makes sense. Where do I find this curry-function, only in the
> book? It appears not to be a standard function.
Bottom of my message before, just type it in. (or go to ActiveState for
the class-based version).
The cookbook site:
The curry recipe:


Example of use in IDLE (followed by code):

 >>> from my_util import curry
 >>> def f(a,b,c): return a*b+c

 >>> g = curry(3)
 >>> assert g(2,1) == 7 == f(3,2,1)

from __future__ import nested_scopes

def curry(*_args, **_kwargs):
     """curry(f,<args>)(<more>) == f(<args>, <more>) (roughly).

     keyword args in the curry call can be overridden by keyword args
     in the later call; curry can be used to change defaults.
     def result(*__args, **__kwargs):
         if _kwargs and __kwargs:
             kwargs = _kwargs.copy()
             kwargs = _kwargs or __kwargs
         return _args[0](*(_args[1:]+__args), **kwargs)
     return result

More information about the Python-list mailing list