eof

Thomas Bellman bellman at lysator.liu.se
Thu Nov 22 09:36:53 EST 2007


Hrvoje Niksic <hniksic at xemacs.org> wrote:

> I don't get it, Python's files are implemented on top of stdio FILE
> objects, which do buffering and provide EOF checking (of the sort
> where you can check if a previous read hit the EOF, but still).  Why
> not export that functionality?

Alexy wants to check if a file is about to hit EOF, not if it has
already hit EOF.  Stdio does not support that.  Nor does Unix.
The only way to check if the file is about to hit EOF, is to
actually perform a read and see if it returns zero bytes.  That
is usually OK to do on plain files, but on pipes, sockets or
terminals, you would have major problems, since suddenly calling
the eof() method would block the process.  Probably not what you
were expecting.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"Life IS pain, highness.  Anyone who tells   !  bellman @ lysator.liu.se
 differently is selling something."          !  Make Love -- Nicht Wahr!



More information about the Python-list mailing list