[Python-ideas] Make partial a built-in

Stephan Houben stephanh42 at gmail.com
Tue Sep 20 14:17:33 EDT 2016


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.

Stephan



2016-09-20 19:48 GMT+02:00 David Mertz <mertz at gnosis.cx>:

> I find myself "partializing" in ways partial() doesn't support more often
> than not. E.g.
>
> lambda first, third: myfunc(first, 42, third)
>
> I think it's good to have partial() in functools, but it's two orders of
> magnitude less common than things that should be in builtins.
>
> On Sep 20, 2016 9:42 AM, "Ryan Gonzalez" <rymg19 at gmail.com> wrote:
> > lambda *args, **kw: myfunc(partial_arg, *args, **kw)
> >
> > which isn't more readable than just:
> >
> > partial(myfunc, partial_func)
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160920/51ae95dd/attachment.html>


More information about the Python-ideas mailing list