Python `map` and arguments unpacking

You can with a lambda:

map(lambda a: function(a[0], **a[1]), arguments)

or you could use a generator expression or list comprehension, depending on what you want:

(function(a, **k) for a, k in arguments)
[function(a, **k) for a, k in arguments]

In Python 2, map() returns a list (so the list comprehension is the equivalent), in Python 3, map() is a generator (so the generator expression can replace it).

There is no built-in or standard library method that does this directly; the use case is too specialised.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)