27 Aug
2020
27 Aug
'20
7:02 a.m.
On 27/08/20 4:32 am, Ricky Teachey wrote:
class Q: def __subscript__(self, method_name, *args, **kwargs): return getattr(self, method_name)(*args, **kwargs) def __getitem__(self, *args, **kwargs): ... # Note that I have made the RHS value the first argument in __setitem__ def __setitem__(self, value, *args, **kwargs): ... def __delitem__(self, *args, **kwargs): ...
This seems like a very convoluted way of going about it as opposed to just adding a new full set of dunders. And I don't see how it actually provides any more flexibility. -- Greg