This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Digitalxero, ajaksu2, berker.peksag, damngamerz, dharriso, eric.araujo, isandler, pitrou, relm, rhettinger, serhiy.storchaka, sonderblade
Date 2017-02-06.06:15:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486361755.08.0.799682119671.issue968063@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-02-06 06:15:55serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, isandler, sonderblade, pitrou, ajaksu2, relm, dharriso, eric.araujo, Digitalxero, berker.peksag, damngamerz
2017-02-06 06:15:55serhiy.storchakasetmessageid: <1486361755.08.0.799682119671.issue968063@psf.upfronthosting.co.za>
2017-02-06 06:15:55serhiy.storchakalinkissue968063 messages
2017-02-06 06:15:54serhiy.storchakacreate