[ python-Feature Requests-776100 ] new function 'islastline' in
fileinput
SourceForge.net
noreply at sourceforge.net
Tue Jun 15 08:09:42 EDT 2004
Feature Requests item #776100, was opened at 2003-07-23 02:49
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=776100&group_id=5470
>Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Edouard Hinard (edhi)
Assigned to: Nobody/Anonymous (nobody)
Summary: new function 'islastline' in fileinput
Initial Comment:
a function 'islastline' is missing to fileinput module.
when that function exists, it is possible to perform an
action at the end of a file like in:
for line in fileinput.input():
processline(line)
if fileinput.lastline():
processfile()
Without this function, the same script looks like:
for line in fileinput.input():
if fileinput.isfirstline() and fileinput.lineno() != 1:
processfile()
processline(line)
processfile()
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-06-15 07:09
Message:
Logged In: YES
user_id=80475
Reclassifying as a feature request.
I'm -0 on complicating this venerable interface. Also, I
find it unnatural for the inside of a loop to be able to
ascertain whether it is in its final iteration. The closest
approximation is the for-else clause which is vary rarely
used in normal python programming. While the OP was able to
sketch a use case, it involved only saving a couple of lines
over what can be done with the existing API.
P.S. There is a less buggy version of the patch at
www.python.org/sf/968063
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=776100&group_id=5470
More information about the Python-bugs-list
mailing list