Seeing next character in an file

Richie Hindle richie at
Tue Jul 29 10:05:53 CEST 2003

> 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.

> 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 "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

Richie Hindle
richie at

More information about the Python-list mailing list