Serhiy Storchaka added the comment:

The patch is outdated. It uses private _buffer attribute which no longer exist 
(see issue15068). But even when _buffer was existing the patch was not correct, 
because _buffer contained only a part of the file.

It is possible to implement islastline(), but at the cost of additional 
buffering. This effectively negates the result of issue15068. The user would 
need to enter two lines first than fileinput could return the fist one from 
stdin. And additional complication slows down reading for all users even if 
they don't need islastline().

If you need islastline() you can use a wrapper:

def yield_line_and_islastline(f):
    try:
        prevline = next(f)
    except StopIteration:
        return
    for line in f:
        yield (prevline, f.isfirstline())
        prevline = line
    yield prevline, True

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue968063>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to