On 31/08/20 3:35 pm, Random832 wrote:

x[(1,)] old arg=(1,); new args=((1,),)?
> x[(1,2)] old arg=(1,2); new args=((1,2),)?

No, I proposed *not* to do those -- putting parens around the
arguments would continue to make no difference, regardless of
which dunder was being called.

Also, do we want to walk the MRO looking for both in turn, or look
for the new one on the whole chain before then looking for the old
one?
I would look for one and then the other -- looking for both in
parallel would be weird, unprecedented and probably not necessary.

Another concern is where a new setitem should put the value argument?

My solution is to put it before the index arguments, e.g.

    def __setindex__(self, value, i, j, k):

Having the user define a __setitem__ that calls the real_setitem if
needed gets around that by leaving the signature up to the user [where
they can e.g. put it in a keyword arg with a name they know they won't need]

If you're worried about people doing things like

   a[1, 2, 3, value = 4] = 5

I'm not sure that's really a problem -- usually it will result in
an exception due to specifying more than one value for a parameter.

If you're creating a class that needs to be able to take arbitrary
keyword indexes, you can use a positional-only parameter for the
value.

    def __setindex__(self, value, /, *args, **kwds):

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/IPCYFPOB2EO4MIAV4CPARWOO2EFRY3TW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to