def save(self, key, value): try: dbm_file = dbm.open('DBMPersistence', 'c') dbm_file[key] = str(value) finally: dbm_file.close()