PEP309 - built-in curry class (revisions)
intentionally at blank.co.uk
Tue Mar 4 08:55:01 CET 2003
On 27 Feb 2003 07:02:24 -0800, scav at blueyonder.co.uk (Peter Harris)
>Several people have said curry() belongs in the standard library
>rather than as a built-in. If so, what should the module name be,
>and what sort of other things might the module contain?
I agree with this for the 'curry' implementation described in the PEP.
If a built-in is chosen, however...
What I think of as natural for currying is simply to omit certain
parameters from the call syntax - e.g. given
def some_fn (a, b, c) :
I might right...
curried_fn = some_fn (, 5, )
This is roughly what the '@' suggestion describes anyway, so if the
'@' as a currying notation does not seem bad.
If the currying needs to be explicit, I would prefer a keyword.
curried_fn = curried some_fn (, 5, )
The point being that I want to be able to curry a middle argument if
necessary. I'm not sure if the use of *args and **kw support this.
That said, I've never been entirely convinced of the need for curry as
either a built-in or as a library in Python. When I want to curry, I
tend to write...
curried_fn = lambda a, c : some_fn (a, 5, c)
...or even, to allowed the curried argument to be un-curried later if
curried_fn = lambda a, b=5, c : some_fn (a, b, c)
This is more long-winded, of course, but I don't necessarily think
that's inappropriate in Python.
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list