A dictionary is populated with consecutive integer keys, like this:
d = dict()
for i in range(0, 10):
d[i] = 100-i
Later, the dictionary items are iterated like this:
for k, v in d.items():
print k, v
The result shows the items are iterated in numerical order:
0 100
1 99
2 98
3 97
4 96
5 95
6 94
7 93
8 92
9 91
It turns out, this is the behavior I want, but not what I expected. I expected dictionary iteration in random order. What's going on here, and can I depend on this behavior in code released publicly?