hello everybody,
I am trying to learn to use Python. Currently, I am
reading Michael Dawson's "Python Programming for the
Absolute Beginner." Right now, I am having the
following problem: I try to read all the pickles in a
file, but keep on getting the same error: EOFError.
This is what the code looks like:
import cPickle, shelve
print "Pickling lists."
variety=["sweet","hot","dill"]
shape=["whole","spear","chip"]
brand=["Claussen","Heinz","Vlassic"]
pickle_file=open("pickles1.dat","w")
cPickle.dump(variety,pickle_file)
cPickle.dump(shape,pickle_file)
cPickle.dump(brand,pickle_file)
pickle_file.close()
print "\nUnpickling lists."
pickle_file=open("pickles1.dat","rb")
for i in pickle_file:
i=cPickle.load(pickle_file)
print i
pickle_file.close()
This is what I keep on getting:
Pickling lists.
Unpickling lists.
Traceback (most recent call last):
File "/Users/davidjimenez/Documents/trypickle", line
20, in -toplevel-
i=cPickle.load(pickle_file)
EOFError
Thank you,
David Jimenez
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor