On 08/10/2019 17:35, Todd wrote:
On Tue, Oct 8, 2019 at 12:22 PM Andrew Barnert via Python-ideas < email@example.com> wrote:
On Oct 7, 2019, at 21:21, Caleb Donovick firstname.lastname@example.org 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.
Here is an example modified from the xarray documentation, where you want to assign to a subset of your array:
da.isel(space=0, time=slice(None, 2))[...] = spam
With this syntax this could be changed to:
da[space=0, time=:2] = spam
Can I just say how glad I am that I never have to deal with pandas? ;-/