[issue24434] ItemsView.__contains__ does not mimic dict_items

Martin Panter report at bugs.python.org
Tue Jun 16 06:23:41 CEST 2015


Martin Panter added the comment:

The trouble with Serhiy’s suggestion is that it would still try to iterate the argument:

>>> i = iter(lambda: print("ITERATION"), "infinity")
>>> i in dict()  # No iteration
False
>>> i in ItemsView(dict())
ITERATION
ITERATION
ITERATION
False

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24434>
_______________________________________


More information about the Python-bugs-list mailing list