Open iloveitaly opened 10 months ago
It makes sense. A nice and backwards compatible addition. I will appreciate a full PR.
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.
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.
The implementation here is converting list to tuple anyway, so not adding anything new.
@SirPavlova you probably need some other behavior
This would be really helpful for me.
Curious what you think! Can write tests + update docs if you think it's a good idea.