file object and eof
sjdevnull at yahoo.com
sjdevnull at yahoo.com
Tue Aug 15 16:11:16 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
1. At least on python 2.3, seek always returns None--did that change in
2.4? I added a tell() in there to fix that.
2. You have your test reversed. It'll always return True as is.
3. Even if you fix that, it's limited utility depending on file mode
and whether the file object is seekable.
What's your actual problem? There's almost certainly a better way to
do it.
More information about the Python-list
mailing list