Another inconsistency is that the case of keyword arguments only would bind the RHS value to the first positional argument, which is the index, and not the value. I think this is what Guido was referring to when he responded talking about introspection being required? Not sure. 

in any case, to me that doesn't seem like such a big deal period it might lead to some weird error messages but I'm not sure why it's such a big problem. Maybe it poses a difficulty for type hinting?

On Sat, Sep 26, 2020, 6:48 PM Christopher Barker <pythonchb@gmail.com> wrote:

On Fri, Sep 25, 2020 at 11:50 PM Steven D'Aprano <steve@pearwood.info> wrote:
>>
>> 1. We have to pass a sentinel to the setitem dunder if there is no
>> positional index passed.


I still don't follow this logic -- why can't nothing be passed? The dunders either require an index or they don't, would that be just like function calling? So (adapting the example in the PEP:

obj[spam=1, eggs=2]
# calls type(obj).__getitem__(obj, spam=1, eggs=2)


This sure seems like the obvious way to handle it. If the class requires a positional argument
then it will fail with a TypeError.

This sure seems like the most straightforward way to handle it.

I'm sure I'm missing something, but reading the PEP, and my own experiments haven't clarified it for me.

NOTE: one inconsistency would be that:

obj[]

would be a SyntaxError,

and

obj[this=x]

would be a TypeError, if a positional index were expected. but that's less weird to me than the other incionsisentcies we are introducing for backward compatibility.

-CHB

--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython