
On Oct 7, 2019, at 21:21, Caleb Donovick <donovick@cs.stanford.edu> wrote:
But what if you wanted to take both positional AND keyword?
I was suggesting that that wouldn't be allowed. So subscript either has a single argument, a tuple of arguments, or a dictionary of arguments. Allowing both has some advantages but is less cleanly integratible.
The problem is that half the examples people conjure up involve both: using the keywords as options, while using the positional arguments for the actual indices. Calling the proposal “kwargs in getitem” encourages that thinking, because that’s the prototypical reason for kwargs in function calls. If there were non-toy examples, so people didn’t have to imagine how it would be used for themselves, that might be helpful. Why is `d[x=1]` useful but `d[1, flag=True]` not needed? If you showed real Pandas queries or whatever instead of toy ones, it might be clearer. And you could challenge people who want flags to give real examples that you could then dissect. Also, an actual __get/set/delitem__ implementation using the proposed feature would help. You can argue that dealing with the dicts-are-iterable issue won’t be a problem in practice, but just showing methods that deal with it and remain perfectly readable makes the case a lot better.