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
_______________________________________________
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/ZWLNKSZ7IU5TGIPZY7CDZBPVQXYPCGT7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to