partial函数可以提高代码利用率和简洁性:
from functools import partial
def power(base, exponent, bias):
return base * exponent + bias
squared = partial(power, exponent=2, bias=100)
In [7]: power(2,2,100)
Out[7]: 104
In [8]: squared(2)
Out[8]: 104
In [9]: squared(2, bias=1000)
Out[9]: 1004