For a function with many arguments, including position and keyword ones. How to specify a list to a keyword argument without repeat previous keyword arguments?
E.g.
import multiprocessing
from functools import partial
def foo(a, b, c=1, d=2, e=3):
print(multiprocessing.current_process().name)
print(a + b + c + d + e)
return a + b + c + d + e
with multiprocessing.Pool(processes=2) as pool:
# I would like to give [1,2,3,4] to "e", something like
# dic = {'e': [1,2,3,4]}
# Yet we still have c = 1, d = 2.
results = pool.map(partial(foo, 2, 3), dic)
The argument list can be long, and I don't want to type "c=1, d=2" in every partial function.
I know it's possible to use multiprocessing.apply
, but I would like keep consistent with other usages of this function, and using map
only.