in other wordsshelve is just go-betweenit serializes and deserializes objects so that they can be placed in string-based dbm files the net effect is that shelves let you store nearly arbitrary python objects on file by key and fetch them back later with the same key your scripts never see all of this interfacingthough like dbm filesshelves provide an interface that looks like dictionary that must be opened in facta shelve is simply persistent dictionary of persistent python objects--the shelve dictionary' content is automatically mapped to file on your computer so that it is retained between program runs this is quite featbut it' simpler to your code than it may sound to gain access to shelveimport the module and open your fileimport shelve dbase shelve open("mydbase"internallypython opens dbm file with the name mydbaseor creates it if it does not yet exist (it uses the dbm 'cinput/output open mode by defaultassigning to shelve key stores an objectdbase['key'object store object internallythis assignment converts the object to serialized byte stream with pickling and stores it by key on dbm file indexing shelve fetches stored objectvalue dbase['key'fetch object internallythis index operation loads string by key from dbm file and unpickles it into an in-memory object that is the same as the object originally stored most dictionary operations are supported heretoolen(dbasedbase keys(number of items stored stored item key index iterable and except for few fine pointsthat' really all there is to using shelve shelves are processed with normal python dictionary syntaxso there is no new database api to learn moreoverobjects stored and fetched from shelves are normal python objectsthey do not need to be instances of special classes or types to be stored away that ispython' persistence system is external to the persistent objects themselves table - summarizes these and other commonly used shelve operations table - shelve file operations python code action description import shelve import get bsddbgdbmand so on whatever is installed file=shelve open('filename'open create or open an existing shelve' dbm file file['key'anyvalue store create or change the entry for key value file['key'fetch load the value for the entry key count len(filesize return the number of entries stored databases and persistence