[Python-ideas] partial with skipped arguments (original) (raw)

Collin Winter collinw at gmail.com
Sun Apr 22 18: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

In Python 2.5.0:

import functools def f(a, b): ... return a + b ... p = functools.partial(f, b=9) p <functools.partial object at 0xb7d66194> p(3) 12

Is this what you're looking for?

Collin Winter



More information about the Python-ideas mailing list