Pickle question
Dave Brueck
dbrueck at edgix.com
Tue Apr 3 12:50:37 EDT 2001
Hi Noel,
I've pickled multi-megabyte files without problems. Did you pickle in binary
or ASCII mode? Did you open the file for reading the same way?
f = open('foo.foo','wb') # binary mode
pickle.dump(obj, f, 1) # binary mode
...
f = open('foo.foo','rb') # binary mode
obj = pickle.load(f)
Binary mode and ASCII mode both work fine, you just have to be consistent.
-Dave
> I'm trying to use pickle to serialize some of my instances to files. The
> pickling operation works fine -- I do not get a pickling error, but when I
> try to unpickle the file, I get the following error:
>
> ====
> Traceback (most recent call last):
>
> File "C:\perforce\blueprint\test\pickleDataTest.py", line 37, in
> testCompleteRun
>
> x = pickle.load(file)
>
> File "c:\python20\lib\pickle.py", line 897, in load
>
> return Unpickler(file).load()
>
> File "c:\python20\lib\pickle.py", line 517, in load
>
> dispatch[key](self)
>
> KeyError:
> ====
>
> The pickle file in question is 83 KB -- is that the problem? I seem to be
> having this problom on all pickle files over about 5 KB. Is there a data
> format in my class that could be causing the problem?
>
> Thanks,
>
> Noel
>
> -------------
> Noel Rappin
> Openwave
> Principal Software Engineer, Internal Development
> Noel.Rappin at openwave.com
> (781) 274-7000 x305
>
> The contents of this email message do not necessarily reflect the opinions
> or programming practices of Openwave Systems
>
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list