[Tutor] cPickle usage
Jorge Louis de Castro
jobauk at hotmail.com
Thu Aug 25 15:05:34 CEST 2005
Hi,
[Sorry for the repost, there was a typo previously]
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.load(self.username, inFile)
cPickle.load(self.age, inFile)
cPickle.load(self.gender, inFile)
cPickle.load(self.totalMsgs, inFile)
cPickle.load(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?
chrs
j.
>
>
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list