On Fri, Sep 25, 2020 at 11:26 PM Ricky Teachey <ricky@teachey.org> wrote:
On Sat, Sep 26, 2020 at 1:51 AM Guido van Rossum <guido@python.org> wrote:
But this requires introspection.
I'm sorry Guido I'm staring at your message and reread mine several times and I don't understand where introspection is required. It seems like all the parser has to do is what it has always done-- pass the arguments to the item dunders and let the chips fall where they may (other than perhaps adjusting the TypeError message that could result). But you don't have to explain to me, I am certain you know what you're talking about.
Anyway: I don't have an opinion on which of the offered possibilities is the best SENTINEL.
But I would also suggest considering adding the Ellipses object, ..., to the list of possibilities. It's a unique value that sort of stands out (though it is Truthy rather than Falsey like None and the empty tuple).
I meant that introspection would be needed to determine whether a default index was given or not. On second thought, I made a mistake, and it's worse -- it's just impossible to do it right from every POV. IIUC you're proposing that the user add a default to the `index` value, like this: ``` def __setitem__(self, index=42, value=None, **kwargs): ... ``` But in order to be correct we'd have to make `index` and `value` (and `self`) positional-only arguments (PEP 570), otherwise you'd get problems with `a[43, value=1] = 2`, so the def should really be ``` def __setitem__(self, index=42, value=None, /, **kwargs): ... ``` But then the interpreter must pass `index` and `value` by position. How would it pass `value` without passing `index`? By keyword -- but we've just determined it must be a positional-only arg. Ergo, we've reached a contradiction, and there's no solution. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>