Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def pluck(key, mappings):
"""Iterates over values for key in mappings."""
return map(itemgetter(key), mappings)
def str_join(sep, seq=EMPTY):
"""Joins the given sequence with sep.
Forces stringification of seq items."""
if seq is EMPTY:
return str_join('', sep)
else:
return sep.join(map(sep.__class__, seq))
def invoke(objects, name, *args, **kwargs):
"""Yields results of the obj.name(*args, **kwargs)
for each object in objects."""
return map(methodcaller(name, *args, **kwargs), objects)
def pluck_attr(attr, objects):
"""Iterates over values of given attribute of given objects."""
return map(attrgetter(attr), objects)