I have been looking for information in Google and stackoverflow, but I dind't find a good solution.
I need to handle a list, add elements, delete elements... but saved in a file. This is in order to avoid losing the list when the execution finish, because I need to execute my python script periodically. Here are alternatives I found, but they have some problems
- Shelve module: can't find how to delete a element in the list (such as
list.pop()
) instead of deleting all the list. pprint.pformat()
: to modify information, I need to delete all the document and save the modifed information, very inefficient.- json: tediuos for just a list and doesn't seems to solve my problem
So, which is the best way to handle a list, doing things as easy as mylist.pop()
keeping the changes in a file in an efficient way?