On Sat, Aug 15, 2020 at 10:00 PM Steven D'Aprano <steve@pearwood.info> wrote:
On Sat, Aug 15, 2020 at 08:26:10PM -0700, Guido van Rossum wrote:

> Are you saying that for xarray it is important to distinguish between
> `d[day=3, detector=4]` and `d[detector=4, day=3]`? If we just passed the
> keyword args to `__getitem__` as an extra `**kwds` argument (which
> preserves order, since Python 3.6 at least), that should work, right? If
> not, can you clarify?


Just to clarify here, I assume you mean that if xarray cares about
order-preserving keywords, they should write their methods this way:

    def __getitem__(self, index=None, **kwargs):

rather than mandating that keyword args are *always* bundled into a
single dict parameter.

Um, I'm not sure what "bundled into a single dict parameter" refers to.

That the signature would be
```
def __getitem__(self, index, kwargs, /):
```
? That sounds bad for people who want to use a few choice keywords. (And I think you'd be against that, for that very reason; as am I.)

Or Jonathan Fine's proposal to create a "Key" class that bundles positional and keyword args? Same thing. (And I *know* you're against that. So am I.)

--
--Guido van Rossum (python.org/~guido)