import shelve
newtimes = ["110pm", "220pm", "300pm", "445pm"]
db = shelve.open("shelved.dat", "w", writeback=1)
for k in db.keys():
obj = db[k]
print "%s: %s" % (k, obj)
flights = db['flights']
times = db['times']
flights['1145'] = "Dallas"
flights['1709'] = "Orlando"
db['times'] = newtimes
db['oldtimes'] = times
db.sync()
for k in db.keys():
obj = db[k]
print "%s: %s" % (k, obj)
db.close()