Jan 19, 2012

Python Standard Library: Functools

partial

New function with partial application of the given arguments and keywords
from functools import partial
def f(a, b=2):
    print a, b

f1 = partial(f, 'fixed_a')
f1(b=777)
# fixed_a 777

f2 = partial(f, b='fixed_b')
f2(777)
# 777 fixed_b

No comments: