object ['the''bright'('side''of')['life']object {'name''brian''age' 'motto'object dbase['brian'object dbase['knight'{'name''knight''motto''ni!'dbase close(herewe open shelve and store two fairly complex dictionary and list data structures away permanently by simply assigning them to shelve keys because shelve uses pickle internallyalmost anything goes here--the trees of nested objects are automatically serialized into strings for storage to fetch them backjust reopen the shelve and indexc:\pp \dbasepython import shelve dbase shelve open("mydbase"len(dbase entries dbase keys(index keysview(list(dbase keys()['brian''knight'dbase['knight'{'motto''ni!''name''knight'fetch for row in dbase keys()keys(is optional print(row'=>'for field in dbase[rowkeys()print('field'='dbase[row][field]brian =motto ['the''bright'('side''of')['life']age name brian knight =motto niname knight the nested loops at the end of this session step through nested dictionaries--the outer scans the shelve and the inner scans the objects stored in the shelve (both could use key iterators and omit their keys(callsthe crucial point to notice is that we're using normal python syntaxboth to store and to fetch these persistent objectsas well as to process them after loading it' persistent python data on disk storing class instances in shelves one of the more useful kinds of objects to store in shelve is class instance because its attributes record state and its inherited methods define behaviorpersistent class databases and persistence