Often the first line of a file tells how to read or interpret the other
lines.
Depending on the result, you then have to ...
- skip the first line, or
- treat the first line in another special way, or
- treat the first line in the same way as the other lines.
I can handle this by opening the file
Egbert Bouwman wrote:
Often the first line of a file tells how to read or interpret the other
lines.
Depending on the result, you then have to ...
- skip the first line, or
- treat the first line in another special way, or
- treat the first line in the same way as the other lines.
I can
On Mon, Aug 16, 2010 at 11:59:57AM +0200, Peter Otten wrote:
with open(filename) as lines:
first_line = next(lines, )
if special(first_line):
# ...
else:
lines = itertools.chain([first_line], lines)
for line in lines:
# ...
Beautiful. And a nice