reading lines 2 at a time
f = open("filename")
for line1, line2 in ?? f ??:
You could do something like this:
with open('myFile.txt') as fh: for line1 in fh: line2 = next(fh) # Code here can use line1 and line2.
You may need to watch for a
StopIteration error on the call to
next(fh) if you have odd lines. The solutions with
izip_longest are probably better able to avoid that need.