30 Aug
2020
30 Aug
'20
12:14 a.m.
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