[Tutor] (no subject)

Jorge Louis de Castro jobauk at hotmail.com
Thu Aug 25 14:56:15 CEST 2005


I think I may have misinterpreted the syntax of cPickle. I have dumped data 
onto a file using:

output = codecs.open(".\\"+self.filename, "ab")
cPickle.dump(self.terms, output)
cPickle.dump(self.username, output)
cPickle.dump(self.age, output)
cPickle.dump(self.gender, output)
cPickle.dump(self.totalMsgs, output)
cPickle.dump(self.occurrences, output)

I thought I could unpickle this using the load feature, something like:
inFile = codecs.open(".\\"+self.filename, "r")
cPickle.load(self.terms, inFile)
cPickle.dump(self.username, inFile)
cPickle.dump(self.age, inFile)
cPickle.dump(self.gender, inFile)
cPickle.dump(self.totalMsgs, inFile)
cPickle.dump(self.occurrences, inFile)

Which would unpickle the data onto the variables. It does not work like 
that, unfortunately. When I try reading the whole file I only get the first 
object read as output.
Any ideas how to achieve what this?


More information about the Tutor mailing list