June 2019
Beginner to intermediate
770 pages
19h 24m
English
The shelve and dbm modules provide immediate access to any object in an arbitrarily huge universe of objects. The shelve module creates a mapping that is much like a dictionary. The shelf mapping exists on persistent storage, so any object we put onto the shelf will be serialized and saved.
We must identify each shelved object with a unique key. String values are a common choice for keys. This imposes some design considerations on our classes to provide an appropriately unique key. In some cases, the problem domain will have an attribute that is an obvious unique key. In that case, we can simply use that attribute to construct this key. For example, if our class has a unique attribute value, key_attribute, we ...
Read now
Unlock full access