import dbm db = dbm.open('definitions', 'c') db['mustard'] = 'yellow' db['ketchup'] = 'red' db['pesto'] = 'green' print(len(db)) #3 print(db['pesto']) #b'green' db.close() db = dbm.open('definitions', 'r') print(db['mustard']) #b'yellow'