When using map, you often want to fix only some arguments, so make a note of it.
Use functools.partial. This object behaves like a function called with arguments.
Consider the case of creating a function that adds two arguments and returns them, and then fixing only one argument.
In [1]: import functools
In [2]: def f(a, b):
...: return a + b
...:
In [3]: map(functools.partial(f, b=1), [1, 2, 3])
Out[3]: [2, 3, 4]
Recommended Posts