This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author markonervo
Recipients alex, collinwinter, eric.araujo, ezio.melotti, gregory_p, markonervo, pitrou, rhettinger, serprex
Date 2011-11-18.19:38:14
SpamBayes Score 6.646143e-07
Marked as misclassified No
Message-id <1321645095.52.0.587027963.issue13430@psf.upfronthosting.co.za>
In-reply-to
Content
> But so does functools.partial. So the question is, what use case does it
> help that functools.partial doesn't?

Sure, it's common `defining new functions on other functions`... more times. Here a stupid example with fold (our reduce).


@curry
def fold(function, start, sequence):
    if len(sequence) == 0:
        return start
    else:
        return fold(function, function(start, sequence[0]), sequence[1:])


Now, someone could be define a generic summer function by fold.


import operator as op

summer = fold(op.add)


Now, an other programmer could be use summer for defining listsummer (a function which sum only list), as follow.


listsummer = summer([])


In addition, curry is cleaver than functools.partial. 


summer = functools.partial(fold, op.add)
listsummer = functools.partial(summer, [])


However, it is an additional feature. Nobody forces you to use it, but if you need it... Yeah, you could rewrite it each time, but why? It is perfect in functools (:
History
Date User Action Args
2011-11-18 19:38:15markonervosetrecipients: + markonervo, collinwinter, rhettinger, pitrou, gregory_p, ezio.melotti, eric.araujo, alex, serprex
2011-11-18 19:38:15markonervosetmessageid: <1321645095.52.0.587027963.issue13430@psf.upfronthosting.co.za>
2011-11-18 19:38:14markonervolinkissue13430 messages
2011-11-18 19:38:14markonervocreate