file object and eof
Fredrik Lundh
fredrik at pythonware.com
Tue Aug 15 17:57:41 EDT 2006
KraftDiner wrote:
> how about?!:
>
> def eof(fileobj):
> curloc = fileobj.tell()
> ofloc = fileobj.seek(0,2)
> fileobj.seek(curloc, 0)
> if ofloc >= curloc:
> return True
> return False
this doesn't work with text files on platforms that translates line
endings, it doesn't work with streams, it's not very efficient, and as
written, it doesn't work at all. and it's entirely pointless, since you
need to check the return value from "read" anyway.
</F>
More information about the Python-list
mailing list