
Modern Python Cookbook
By :

A dictionary is one kind of Python mapping. The built-in type dict
class provides a number of common features. There are some common variations on these features defined in the collections
module.
As we noted in the Choosing a data structure recipe at the beginning of the previous chapter, we'll use a dictionary when we have a key that we need to map to a given value. For example, we might want to map a single word to a long, complex definition of the word, or perhaps some value to a count of the number of times that value has occurred in a dataset.
A dictionary with keys and integer counts is very common. We'll look at a detailed recipe that shows how to initialize the dictionary and update the counter.
We'll look at an algorithm for locating the various stages in transaction processing. This relies on assigning a unique ID to each request and including that ID with each log record...