STINNER Victor added the comment: dict.keys() has been changed 5 years ago, when Python 3 was created.
dict.keys() is now a nice read-only view of dictionary keys. When the dictionary is updated, the view is also updated. See the documentation: http://docs.python.org/3/library/stdtypes.html#dict-views The view is not a sequence: isinstance({}.keys(), collections.Sequence) is False. If you want a list, you must write list(dict.keys()) > Now of course it makes no sense to check if a dict (not washable because it's > mutable) is a key in a dictionary I still don't understand your problem. What is your usecase? Yes, Python 3 is a new language. It's a better language in my opinion, because it now has the good behaviour. > Should this have been done for performance reasons, Yes, avoiding a temporary list is more efficient in "for k in dict: ..." and "for k, v in dict.items(): ...". ---------- _______________________________________ 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