useful things to picklebecause they provide both data (attributesand behavior (methods)in factthe combination is roughly equivalent to "recordsand "programs because pickle is so generalit can replace extra code you might otherwise write to create and parse custom text file representations for your objects by storing an object' pickle string on fileyou effectively make it permanent and persistentsimply load and unpickle it later to re-create the original object the shelve module although it' easy to use pickle by itself to store objects in simple flat files and load them from there laterthe shelve module provides an extra layer of structure that allows you to store pickled objects by key shelve translates an object to its pickled string with pickle and stores that string under key in dbm filewhen later loadingshelve fetches the pickled string by key and re-creates the original object in memory with pickle this is all quite trickbut to your script shelve of pickled objects looks just like dictionary--you index by key to fetchassign to keys to storeand use dictionary tools such as leninand dict keys to get information shelves automatically map dictionary operations to objects stored in file in factto your script the only coding difference between shelve and normal dictionary is that you must open shelves initially and must close them after making changes the net effect is that shelve provides simple database for storing and fetching native python objects by keysand thus makes them persistent across program runs it does not support query tools such as sqland it lacks some advanced features found in enterprise-level databases (such as true transaction processing)but native python objects stored on shelve may be processed with the full power of the python language once they are fetched back by key storing objects on shelve database pickling and shelves are somewhat advanced topicsand we won' go into all their details hereyou can read more about them in the standard library manualsas well as application-focused books such as the programming python follow-up text this is all simpler in python than in englishthoughso let' jump into some code let' write new script that throws objects of our classes onto shelve in your text editoropen new file we'll call makedb py since this is new filewe'll need to import our classes in order to create few instances to store we used from to load class at the interactive prompt earlierbut reallyas with functions and other variablesthere are two ways to load class from file (class names are variables like any otherand not at all magic in this context) yeswe use "shelveas noun in pythonmuch to the chagrin of variety of editors 've worked with over the yearsboth electronic and human more realistic example