[Python] curry?

horst horsu at freeshell.ORG
Thu Oct 5 16:12:36 PDT 2006


> Date: Thu, 5 Oct 2006 15:07:44 -0700
> From: Bob Miller <kbob at jogger-egg.com>
> 
> Rob Hudson wrote:
>
>> I think, in general, there's a concept about "curry" or "currying" that
>> I'm not familiar with.
>
> There's less to currying than meets the eye.  Currying a function
> means providing values for some of its arguments.
>
...
> It's a bit of a mystery to me why this concept deserves a name.
>
> In Python, you'd be more likely to write foo with default args.
  ...
I agree.
At least when you are in control of  both functions --if foo() comes from 
somewhere else, with positional arguments, then it makes sense to 'curry' or...:

It seems like that's what functools.partial in python 2.5 is doing.
  http://docs.python.org/whatsnew/pep-309.html

Given above
def foo(a, b, c):

import functools
bar = functools.partial(foo, a='aye', c='see')

It's not that I couldn't live without this -- I am just entertaining the idea.
((But then, I haven't even installed 2.5 ...))

  - Horst



More information about the Python mailing list