Presumably this was inspired by the other thread, "Add __keys__ or
__items__ protocol", where an __items__() method was proposed instead of
recognizing mappings by the presence of a keys() method.

On Tue, Feb 18, 2020 at 12:46 PM Rhodri James <rho...@kynesim.co.uk> wrote:

> On 18/02/2020 20:33, Soni L. wrote:
> >
> >
> > On 2020-02-18 5:08 p.m., Rhodri James wrote:
> >> On 18/02/2020 19:43, Soni L. wrote:
> >>> It'd be nice to have a __valid_getitem_requests__ protocol that, if
> >>> present, yields pairs such that:
> >>>
> >>> for key, value in items(obj):
> >>>    assert obj[key] == value
> >>>
> >>> for any obj.
> >>
> >> OK, I'll bite.  What is this "items()" function you apply to the
> >> arbitrary object?
> >>
> > Similar to len(). Just a shitty wrapper for __valid_getitem_requests__.
>
> Language, sunshine.
>
> Do you have a use case for this, or is it just theoretically nice to
> have?  I have to say it isn't nice enough for me to actually want it,
> and I say that as someone who regularly forgets that iterating over a
> dict gets you its keys.
>
> --
> Rhodri James *-* Kynesim Ltd
> _______________________________________________
> 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/3W4UBUL6QTONUZN2XFSVAPVKZTHO62PU/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
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/Q26OAZRX44VGBEPWIJAVTEXSJIKQBUDO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to