[Python-ideas] partial with skipped arguments

Steven Bethard steven.bethard at gmail.com
Sun Apr 22 07:14:01 CEST 2007

On 4/21/07, Calvin Spealman <ironfroggy at gmail.com> wrote:
> I often wish you could bind to arguments in a partial out of order,
> skipping some positionals. The solution I came up with is a singleton
> object located as an attribute of the partial function itself and used
> like this:
> def foo(a, b):
>     return a / b
> pf = partial(foo, partial.skip, 2)
> assert pf(1.0) == 0.5

The other way I've seen this proposed is as::

    rpartial(foo, 2)

In this particular situation, you could also just write::

    partial(foo, b=2)

I think the presence of keyword argument support is why rpartial
wasn't added originally.

I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy

More information about the Python-ideas mailing list