Checking for end of a file

Ralf Laukien lau at adtranzsig.de
Fri Jul 21 02:20:32 EDT 2000


Two possibilities for text file iteration:

I)

for row in file.readlines():
  .....

II)

row = file.readline()

while row != '':
  .....
  row = file.readline()


Ralf

CB schrieb:
> 
> If I'm iterating through a text file, reading one line at a time within a
> while statement, how do I check for the end of file.  I tried while
> filename.eof and filename.eof() but to no avail?
> 
> Colin



More information about the Python-list mailing list