Skip to content

Commit

Permalink
feat: allow multiple keys to be passed to pluck
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Dec 14, 2023
1 parent f9e3417 commit 93bee01
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions funcy/colls.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,11 @@ def where(mappings, **cond):
return filter(match, mappings)

def pluck(key, mappings):
"""Iterates over values for key in mappings."""
return map(itemgetter(key), mappings)
"""Iterates over values for key, or multiple keys, in mappings."""
if isinstance(key, (list, tuple)):
return map(itemgetter(*key), mappings)
else:
return map(itemgetter(key), mappings)

def pluck_attr(attr, objects):
"""Iterates over values of given attribute of given objects."""
Expand Down

0 comments on commit 93bee01

Please sign in to comment.