27 Aug
2020
27 Aug
'20
11:32 a.m.
I'm not seeing what problem adding a new dunder and indirection of
__*item__ solves...
It kills at least 3 birds with one stone:
Actually there's a fourth bird. 4. Once you've decided on the signature of your key/index translation dunder, you can ignore the signature in the rest of the item dunders: class C: def __subscript__(self, x, y): return (y,), dict(x=x) def __getitem__(self, *args, **kwargs): print(args, kwargs)
C()[100, y='foo'] (100,), {'y': 'foo'}