2
I made a basic program to store some data and I am in trouble if the user chooses the option to delete some stored dictionary key. The function that erases data in my program is this:
def EraseData(name):
'''
Apaga uma chave do dicionário do banco de dados.
'''
db = dbm.open('data.db', 'c')
del db[name]
db.close()
When I search the entries in my database I see that NOTHING has been deleted. It just doesn’t work.
This is the link to all my code from GIT
:https://github.com/JeffersonCarvalh0/Armazenamento-de-dados/blob/master/armazenamento.py
I think you can help here. http://stackoverflow.com/questions/5844672/delete--element-from-a-dictionary
– Marconi
But I don’t want to keep the database and delete a copy, I really want to change it. However, even using the
del
I can’t. I realized that by interactive mode, when I run exactly the same lines I have in the function, I can delete the key, but by function does not work.– Jefferson Carvalho
So, you need to further detail your error. The function is correct, it works perfectly. Your program, however, has some errors not working properly. I fixed the errors and everything worked perfectly. Are you sure that’s the problem you exposed?
– ppalacios