5.2 Shrinking dictionaries – the pop() method and the del statement
A common use case for a dictionary is as an associative store: it keeps an association between key and value objects. This means that we may be doing any of the CRUD operations on an item in the dictionary:
Create a new key and value pair.
Retrieve the value associated with a key.
Update the value associated with a key.
Delete the key (and the corresponding value) from the dictionary.
5.2.1 Getting ready
A great deal of processing supports the need to group items around one (or more) different common values. We’ll return to the log data shown in the Creating dictionaries – inserting and updating recipe in this chapter.
We’ll use an iterator algorithm that uses the transaction ID as a key in a dictionary. The value for this key will be the sequence of steps for the transaction. With a very...