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

Reply via email to