Raymond Hettinger added the comment:

> I think the problem is that the API of dict.keys() is surprising.
> One gets back something that behaves like a list, the name 'keys'
> suggests that it is a list and for lists there is no requirement 
> that their containing items need to be hasheable.

The keys() method returns a view with set-like behavior (it supports union, 
intersection, difference, fast membership testing using hashed lookups, and 
iteration).

Guido modeled this behavior from a well established API in Java.

FWIW, it is hard for us to do anything about comments like "I was surprised 
..."   The language behaviors are documented but that doesn't help if the docs 
aren't read.  If you expected a list-like object but received a set-like 
object, then you would get surprised.  There is not much that can be done about 
that.

----------
nosy: +rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20190>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to