this bookthoughi'll defer to other resources for more on this topic why you will careclasses and persistence 've mentioned python' pickle and shelve object persistence support few times in this part of the book because it works especially well with class instances in factthese tools are often compelling enough to motivate the use of classes in general--by pickling or shelving class instancewe get data storage that contains both data and logic combined for examplebesides allowing us to simulate real-world interactionsthe pizza shop classes developed in this could also be used as the basis of persistent restaurant database instances of classes can be stored away on disk in single step using python' pickle or shelve modules we used shelves to store instances of classes in the oop tutorial in but the object pickling interface is remarkably easy to use as wellimport pickle object someclass(file open(filename'wb'pickle dump(objectfilecreate external file save object in file import pickle file open(filename'rb'object pickle load(filefetch it back later pickling converts in-memory objects to serialized byte streams (in pythonstrings)which may be stored in filessent across networkand so onunpickling converts back from byte streams to identical in-memory objects shelves are similarbut they automatically pickle objects to an access-by-key databasewhich exports dictionarylike interfaceimport shelve object someclass(dbase shelve open(filenamedbase['key'object save under key import shelve dbase shelve open(filenameobject dbase['key'fetch it back later in our pizza shop exampleusing classes to model employees means we can get simple database of employees and shops with little extra work--pickling such instance objects to file makes them persistent across python program executionsfrom pizzashop import pizzashop shop pizzashop(shop servershop chef (import pickle pickle dump(shopopen('shopfile pkl''wb')this stores an entire composite shop object in file all at once to bring it back later in another session or programa single step suffices as well in factobjects restored this way retain both state and behavioroop and composition"has-arelationships