Top White Papers
Python4Kids: New Tutorial - An Awful PickleFeb 07, 2011, 07:02 (0 Talkback[s])
(Other stories by Brendan Scott)
[ Thanks to Brendan Scott for this link. ]
"So, we know how to save trivia questions to a file, and how to read them back from a file in the future. Moreover, we have decided on a particular way of structuring the data which makes a question. That is, the question is followed by the correct answer and then a number of incorrect answers. Now we have to translate between a list (which has a concept of elements), and a file (which doesn't). Files are "flat" – which is to say that they have no sense of structure, they are simply a stream of data. A file may record all of the characters which are the questions and answers, but it wouldn't record the fact that they are a list or, indeed, that they are any kind of Python object. I was originally just going to run with this to let you find out about files, but I have instead decided to introduce a further concept – the Python pickle!
0 Talkback[s] (click to add your comment)