Anonymous user
Input loop: Difference between revisions
→{{header|Python}}: Add fileinput
(→{{header|AWK}}: (Absent match matches every record).) |
(→{{header|Python}}: Add fileinput) |
||
Line 242:
lines = my_file.readlines() # returns a list of the rest of the lines from the file</python>
This does not mix well with the iteration, however.
When (multiple) filenames are given on the command line:
<python>import fileinput
for line in fileinput.input():
pass # process line, includes newline</python>
The fileinput module can also do inplace file editing, follow line counts, and the name of the current file being read etc.
=={{header|Ruby}}==
|