The worst that could happen would be that some user figures out they can access the hidden functionality by writing a[key, extra=“stuff”], whereas previously they would have to call a.__getitem__(key, extra=“stuff”).

Doesn’t sound like a big deal, and not breakage either.

On Sat, Aug 22, 2020 at 11:09 Christopher Barker <pythonchb@gmail.com> wrote:
On Thu, Aug 20, 2020 at 9:16 PM Random832 <random832@fastmail.com> wrote:
On Thu, Aug 20, 2020, at 20:09, Steven D'Aprano wrote:


> This is likely to be a rare and unusual case, but we don't want to break


> anyone who already has a dunder something like this:


>


>     def __getitem__(self, index, extra=None)





People do similar things with regular arguments to regular functions now, trusting callers not to pass stuff in for no reason that will break the function has been adequate there.

Yes, but this is a little different in that the [] operator will never pass in anything else, but if we make this change, then it might -- so this is a breaking change in this case. And having keywords in the square brackets pass keyword args to the dunder could,m in fact break this use case, whereas passing a new keyword_index object would not.

But as I said in an earlier note -- having ezra keyword parameters on __getitem__ is an abuse of the system anyway, so I think it's OK to break that.

-CHB


 


_______________________________________________


Python-ideas mailing list -- python-ideas@python.org


To unsubscribe send an email to python-ideas-leave@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/XYYOGRZ673D4S7YLGGZBMB6QJ4CXNC3U/


Code of Conduct: http://python.org/psf/codeofconduct/




--
Christopher Barker, PhD

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


_______________________________________________

Python-ideas mailing list -- python-ideas@python.org

To unsubscribe send an email to python-ideas-leave@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/USN6UTQ7HR4NU24V4ITP4WGFDU23MLZW/

Code of Conduct: http://python.org/psf/codeofconduct/

--
--Guido (mobile)