[Python-Dev] Partial function application 'from the right'

Scott David Daniels Scott.Daniels at Acm.Org
Fri Jan 30 18:33:15 CET 2009

scav at blueyonder.co.uk wrote:
> Hi all,
>> On Thu, Jan 29, 2009 at 6:12 AM, Ben North <ben at redfrontdoor.org> wrote:
>>> I find 'functools.partial' useful, but occasionally I'm unable to use it
>>> because it lacks a 'from the right' version.
> -1
> For me, the main objection to a partial that places
> its stored positional arguments from the right is
> that you don't know which positions those arguments
> will actually occupy until the partial is called.

Certainly this interacts in a magical way with keyword args.
That definitional problem is the reason there was no curry_right
in the original recipe that was the basis of the first partial.

If you have:
     def button(root, position, action=None, text='*', color=None):
     blue_button = partial(button, my_root, color=(0,0,1))

Should partial_right(blue_button, 'red') change the color or the text?
It is computationally hard to do that (may have to chase chains of
**kwarg-passing functions), but even hard to document.

So, I'd avoid it.

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-Dev mailing list