[Tutor] cPickle.load()

David Jimenez rimbaudmiller at yahoo.com
Sat Jul 16 18:53:16 CEST 2005


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




		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 


More information about the Tutor mailing list