In [1]:
# Collections

Import directives

In [2]:
import collections

Ordered dictionaries

In [3]:
d = collections.OrderedDict()

d["2"] = 2
d["3"] = 3
d["1"] = 1

print(d)

print(type(d.keys()))
print(list(d.keys()))

print(type(d.values()))
print(list(d.values()))

for k, v in d.items():
    print(k, v)
OrderedDict([('2', 2), ('3', 3), ('1', 1)])
<class 'odict_keys'>
['2', '3', '1']
<class 'odict_values'>
[2, 3, 1]
2 2
3 3
1 1