On Wed, Jul 01, 2020 at 01:07:34PM +0200, Dominik Vilsmeier wrote:

> What is the reason for `dict.items` to return a set-like object?

This is the third time I've linked to the PEP:

https://www.python.org/dev/peps/pep-3106/

More than that, you would have to ask Guido, or the designers of the 
Java framework that inspired it.


>     >>> from collections.abc import Set
>     >>> isinstance({'a': []}.items(), Set)
>     True
> 
> `dict.items` could provide all of its "standard" behavior (like
> membership testing, reversing, etc) without being set-like.

Its standard behaviour includes set-like unions and intersections, and 
has done for over a decade, back to 3.0 and 2.7.



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

Reply via email to