Currying能泛化称为偏函数应用(Partial Function Application, PFA),这种函数将任意数量(顺序)的参数的函数转化成另一个带剩余参数的函数对象。
from operator import add, mul
from functools import partial
add1 = partial(add, 1) #add1(x) == add(1, x)
mul10 = partial(mul, 10) #mul10 == mul(10, x)
baseTwo = partial(int, base = 2)
baseTwo.__doc__ = 'Convert base 2 string to an int'
baseTwo('10010')
摘自《Python核心编程》