I want to read huge text file line by line (and stop if a line with \"str\" found). How to check, if file-end is reached?
fn = \'t.log\'
f = open(fn, \'r\')
There are situations where you can't use the (quite convincing) with... for... structure. In that case, do the following:
line = self.fo.readline()
if len(line) != 0:
if 'str' in line:
break
This will work because the the readline() leaves a trailing newline character, where as EOF is just an empty string.