readline in while loop

Geert Fannes geert.fannes at esat.kuleuven.ac.be
Fri May 23 08:09:12 EDT 2003


hello, i tried to construct a program to read a file, line after line. i 
have no idea why it does not work...

f=file("test.txt","r");
while l=f.readline():
	print l;

the problem is with "while l=f.readline():" the next program does work

f=file("test.txt","r");
while f.readline():

i tried things like

f=file("test.txt","r");
while (l=f.readline())!="":
	print l;

but that doesn't work either. just reading the lines is not enough, i 
want to do something with the read lines.

geert.





More information about the Python-list mailing list