I need to read the file line by line, and I need to look at the "next line", so first I read the file in the list, and then go to the list ... somehow it seems rude, creating a list can become expensive.
for line in open(filename, 'r'):
lines.append(line[:-1])
for cn in range(0, len(lines)):
line = lines[cn]
nextline = lines[cn+1] # actual code checks for this eof overflow
there should be a better way to iterate over the lines, but I don't know how to look ahead
source
share