File: class/Workbook/Examples/Lecture12/testdbm.txt
% python >>> import anydbm >>> file = anydbm.open('languages', 'c') # create >>> file['perl'] = "Text processing" # store >>> file['tcl'] = "Simple glue" >>> file['python'] = "OO scripting" >>> file.close() % python >>> import anydbm >>> file = anydbm.open('languages', 'c') # existing >>> file['python'] # fetch 'OO scripting' >>> for lang in file.keys(): # index ... print lang + ':', file[lang] ... perl: Text processing tcl: Simple glue python: OO scripting >>> del file['tcl'] # delete % python >>> import anydbm >>> anydbm.open('languages', 'c').keys() # sorry, tcl! ['python', 'perl']