Map splat: treat each element as keyword arguments to be passed to the input function #148
Open
Description
What I'd like to do is instead of writing something like:
id_list = [{'id': 1}, {'id': 2}, {'id': 3}]
results = lmap(
lambda args: call_external_api(**(args | {"limit": 100})),
id_list
)
I could instead create a partial on the method call and then just pass it to map:
id_list = [{'id': 1}, {'id': 2}, {'id': 3}]
results = lmap(partial(call_external_api, limit=100), id_list)
However, each element of the array is passed as a positional argument instead of splatted as keyword arguments. Any ideas of how to write map in a way that it splats the element and assumes it's a dictionary that should be converted into keyword arguments?
Should this be an additional map variant added to the library? Happy to write up a PR for it.
Metadata
Assignees
Labels
No labels