On 30/08/20 3:49 am, Adam Johnson wrote:
def _parse_subscripts(self, /, x, y):
return x, y
def __getitem__(self, item=MISSING, /, **kwargs):
if item is MISSING:
args = ()
elif isintance(item, tuple):
args = item
else:
args = (item,)
x, y = self._parse_subscripts(*args, **kwargs)
return do_stuff(x, y)
I think this could be done more simply as
def __getitem__(self, index, **kwds):
self.real_getitem(*index, **kwds)
def real_getitem(self, x, y):
...
The point about obscuring the signature still remains, though.
Also, this is a hack that we would never be able to get rid of,
whereas new dunders would provide a path to cleaning things up
in the future.
--
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/D74BEJSWA7CTPZIZ2CHTTPE4SGWHH4ZG/
Code of Conduct: http://python.org/psf/codeofconduct/