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

Conversation

iloveitaly
Copy link
Contributor

This would be really helpful for me.

Curious what you think! Can write tests + update docs if you think it's a good idea.

@Suor
Copy link
Owner

Suor commented Dec 14, 2023

It makes sense. A nice and backwards compatible addition. I will appreciate a full PR.

@Suor
Copy link
Owner

Suor commented Jan 18, 2024

Thinking a bit more your implementation and func interface itself is not backwards compatible. Passing a tuple as a key already has meaning:

pluck(('a', 'b'), [{('a', 'b'): 42}]) == 42 

So maybe pluck(*keys, mappings) instead.

@SirPavlova
Copy link

Only hashable objects can be used as keys, so passing pluck a list of keys wouldn't cause the same ambiguity that passing a tuple of keys does.

And it makes sense to specify multiple keys as a collection, especially a list or set.

Tuples aren't viable due to being valid keys, but they would be fairly conceptually iffy here anyway. A list is a sequential collection containing separate objects, but a tuple is a single object that just happens to have a sequential internal structure. Passing a tuple of keys doesn't really make sense.

@Suor
Copy link
Owner

Suor commented May 1, 2024

The implementation here is converting list to tuple anyway, so not adding anything new.

@SirPavlova you probably need some other behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants