On Sat, Aug 11, 2012 at 6:30 PM, Richard D. Moores <rdmoo...@gmail.com> wrote: > > I wrote pickle_attempt.py as an exercise to try to learn to use the > pickle module. See the version I edited for Tutor, > pickle_attempt_for_web.py at > <http://pastebin.com/SNwKRuSK>. > .... > But after closing the program and restarting it, those items have > disappeared from D.
On line 68 you open the file in 'ab' mode. A pickle stream ends with an ASCII period (\x2e). Anything appended after that is ignored. Use 'wb' mode. Also, Python 3.x defaults to protocol 3, which is binary, so you might want a file extension other than .txt, such as .pkl, .dat, .bin, etc. If you're curious about the protocol, you can disassemble a pickle using pickletools.dis(pickle), where pickle is bytes or a file-like object. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor