Simple Pickle Question!

Jeff Epler jepler at unpythonic.net
Tue Jul 16 16:43:27 EDT 2002


You must "seek" the file to the beginning to read it again from the
beginning.

Here's an example without the use of pickle:
f = open("test_readwrite", "w+")
f.write("hi there")
# f.seek(0)
print `f.read()`

If you uncomment the 'seek' line, you'll get some text in f.read().
Otherwise, you'll get an empty string (EOF).

Pickle doesn't seem to handle premature EOF well.. (the missing key is
probably the empty string)

Jeff





More information about the Python-list mailing list