[Tutor] write problem
Paul Sidorsky
paulsid@shaw.ca
Thu, 10 Jan 2002 15:50:21 -0700
Danny Yoo wrote:
> The file position is at the end of the file, so you won't be able to read
> what you've immediately written until you rewind the file. What you'll
> probably want to do is rewind or "seek()" back to the beginning of the
> file:
>
> ###
> data.seek(0)
> ###
Furthermore, a seek should always be done before changing from reading
to writing (or vice-versa) in any case. Some implementations of C
(which Python is written in) will do unpredictable things if this isn't
done. I'm not sure if Python insulates against this or not but it's
probably a good idea not to take the chance.
--
======================================================================
Paul Sidorsky Calgary, Canada
paulsid@shaw.ca http://members.shaw.ca/paulsid/