Why doesn't this simle DCurry-like implementation work?

John J. Lee jjl at pobox.com
Sun Oct 28 12:59:16 EST 2001


On Sun, 28 Oct 2001, Michael R. Head wrote:

> On Sun, Oct 28, 2001 at 09:57:01AM -0500, python-list-request at python.org wrote:
[...]
> You are right. That's what I get for posting while drunk. I meant:
>
> # this doesn't work...
> def curry(f, p):
> 	return lambda x: f(p, x)
>
> however, now I know that this does work, and does what I want:
>
> def curry(f, p):
> 	return lambda x, ff=f, pp=p: ff(pp,x)

and the simpler (lambda x: f(p, x)) version will work under Python 2.1
with

from __future__ import nested_scopes

Or under 2.2, with no import required, IIRC.


John




More information about the Python-list mailing list