[Python-ideas] Make partial a built-in
אלעזר
elazarg at gmail.com
Tue Sep 20 14:45:44 EDT 2016
On Tue, Sep 20, 2016 at 9:18 PM Stephan Houben <stephanh42 at gmail.com> wrote:
> I must admit I am a bit partial to partial, you can do fun things like
> this:
>
> >>> from functools import partial
> >>> @partial(partial, partial)
> ... def add(x, y):
> ... return x+y
> ...
> >>> add(3)(4)
> 7
>
> I suppose that isn't exactly going to convince Guide to put it in
> builtins, though.
>
> I quietly LOLed, but note that for three arguments you'll need
@partial(partial, partial(partial, partial))
def add(a, b, c): return a + b + c
>>> add(1)(2)(3)
6
So @curry is the transitive closure or something :)
Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160920/60aaf28e/attachment.html>
More information about the Python-ideas
mailing list