There is a command in DBM module to delete the value stored at a key.
del d[key] # delete data stored at key (raises KeyError # if no such key)
But I cannot even iterate with this command, because the Runtime error occurs.(RuntimeError: dictionary changed size during iteration.)
import dbm
db=dbm.open("file.db","c")
for key in db:
del db[key]
print(len(db))
db.close()
Is there an efficient way to empty DMB file at once? I am using Python 3.3