Why a text file? If you simply want to preserve information from session to session, there are three waysWhat you suggested: Write the data to a text file
Pickle , Python's object serializer module (actually: Use cPickle)
Use a database
I recommend you use pickle. However if you choose to move ahead with option 1, note the "%r" formatting directive for example:
s = {'one':'uno', 2:'dos', 'cat': 'gato'}
print ("%r"%s)
You can then use the eval builtin function to recover the data. Beware of quote issues.
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256