[New-bugs-announce] [issue20190] dict() in dict(foo='bar') raises

Martin Häcker report at bugs.python.org
Wed Jan 8 14:35:00 CET 2014


New submission from Martin Häcker:

I was quite surprised by this behavior:

>>> dict() in [dict()]
True
>>> dict() in []
False
>>> dict() in dict(foo='bar').keys()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
>>> dict() in list(dict(foo='bar').keys())
False

I think it should change. Calling dict.keys() one expects to get list like behavior and not having to ensure that everything that is checked for inclusion there has to be hasheable.

If it helps, this is also a regression from python 2.6/7 where this works as expected.

----------
messages: 207683
nosy: dwt
priority: normal
severity: normal
status: open
title: dict() in dict(foo='bar') raises
versions: Python 3.2

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


More information about the New-bugs-announce mailing list