Seeing next character in an file

Richie Hindle richie at entrian.com
Tue Jul 29 04:05:53 EDT 2003


[Richie]
> seek() works perfectly with text-mode files as long as you only seek to
> places given to you by tell().  So if Keith's peek() function had used
> tell() and then seek()ed (sought()? 8-) back to that point like his
> peekline() does, there would be no problem.

[Bengt]
> Can you cite a C or C++ standard section that guarantees that seek/tell
> will work that way in text mode? (I'm not saying there isn't one, but
> I couldn't find one quickly ;-)

ANSI C, ISO/IEC 9899:1990, section 7.9.9.2: "For a text stream, either
offset shall be zero, or offset shall be a value returned by an earlier
call to the ftell function on the same stream and whence shall be
SEEK_SET."

-- 
Richie Hindle
richie at entrian.com






More information about the Python-list mailing list