Dict views notes
Closed this issue · 0 comments
hroncok commented
http://portingguide.readthedocs.io/en/latest/dicts.html#dict-views-and-iterators
I miss an important piece of information: The views cannot be directly accessed with [index]
:
>>> d = {'a': 1, 'b': 2}
>>> d.keys()[0]
'a'
>>> d = {'a': 1, 'b': 2}
>>> d.keys()[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'dict_keys' object does not support indexing