Unnatural behaviour in Pickling

Pekka Niiranen pekka.niiranen at wlanmail.com
Thu Jun 17 08:33:12 EDT 2004


Hi there,

why must file be opened in "r" -mode, before loading works
with Pickling? This forces me to close the file between pickle.dump
and pickle.load. :(

Example:
-----************------

a = {'pekka': 1, 'jussi': 2}
fh = open('c:\temp\log.log', "wb")
pickle.dump(a,fh)
fh.close()

**** now:
fh = open('c:\temp\log.log', "wb")
b = pickle.load(fh)
**** gives error:
IOError: (0, 'Error')

**** however:
fh = open('c:\temp\loglog', "rb")
b = pickle.load(fh)
**** works.

-pekka-






More information about the Python-list mailing list