[issue24434] ItemsView.__contains__ does not mimic dict_items
Caleb Levy
report at bugs.python.org
Fri Jun 12 07:48:18 CEST 2015
Caleb Levy added the comment:
@serhiy.storchaka: I don't think that will work.
First of all,
x, y = item
will raise a ValueError if fed an iterable whose length is not exactly 2, so you would have to check for that. Moreover, if item is something like a dict, for example, then:
{"a": 1, "b": 2} in DictLikeMapping(a="b")
could return True, which I don't think would be expected behavior.
I'm not terribly fond of the instance check myself, but in this case I can't see any other way to do it: the built in dict_items necessarily consists of *tuples* of key-value pairs.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24434>
_______________________________________
More information about the Python-bugs-list
mailing list