Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow multiple keys to be passed to pluck #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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