Skip to content

Latest commit

 

History

History
26 lines (23 loc) · 597 Bytes

5l99-dictionary-view.md

File metadata and controls

26 lines (23 loc) · 597 Bytes

Dictionary View

#python #efficiency #programming #language

  • It is high performance operations on dictionaries
  • If the object changes the view changes as well.
  • It is iterable
>>> d = dict(a=10, b=20, c=30)
>>> values = d.values()
>>> values
dict_values([10, 20, 30])
>>> len(values)
3
>>> list(values)
[10, 20, 30]
>>> reversed(values)
<dict_reversevalueiterator object at 0x10e9e7310>
>>> values[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'dict_values' object is not subscriptable

References

  • Ramalho, 2033, p101-103