Simple Pickle Question!

Derek Basch dbasch at yahoo.com
Tue Jul 16 16:37:11 EDT 2002


Hello All, 
If I open a file object in 'w+' mode and then try a
simple pickle.dump() and pickle.load() such as:

self.foofile = open('foofile', 'w+')
self.foo = 'fudgesticks'
                
pickle.dump(self.foo, self.foofile)              
self.returned = pickle.load(self.foofile)
foofile.close()
print self.returned 

I get this error:    
 File "C:\DOCUME~1\User\DESKTOP\tempers.py", line 259,
in __init__
   self.returned = pickle.load(self.foofile)
 File "C:\Python21\lib\pickle.py", line 947, in load
   return Unpickler(file).load()
 File "C:\Python21\lib\pickle.py", line 567, in load
   dispatch[key](self)
KeyError:

Pickling works fine if I open the file object in 'w'
mode for the dump and again in 'r' for the load.
Any ideas??

if reply > 0:
print 'thanks'

Derek T Basch



__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com





More information about the Python-list mailing list