Simple Pickle Question!

Derek Basch dbasch at yahoo.com
Thu Jul 18 00:04:35 EDT 2002


Jeff,
Thanks for the reply. Your answer was just what I was
looking for. I am using a try: except: to catch the
EOFError. Any other ways to handle an empty file?
Thanks,
Derek Basch

--- Jeff Epler <jepler at unpythonic.net> wrote:
> 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


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





More information about the Python-list mailing list