Re: read a file line by line using readline()

2006-03-22 Thread Bruno Desthuilliers
Phoe6 a écrit : > Hi all, > I just read the manual and got to know I can use a for loop to iterate > through the lines in the file. > > But so far, I was strugling with the following: > > import os > file = open('File1.txt','r') 'file' is the builtin type for file objects (like the one returned

Re: read a file line by line using readline()

2006-03-22 Thread Phoe6
Thomas Girod wrote: > > while line != "": > > and it works very well. Thanks Thomas, I stand corrected now. my mistake, I was checking against a single space ' ' instead of empty string ''. :( -- Senthil -- http://mail.python.org/mailman/listinfo/python-list

Re: read a file line by line using readline()

2006-03-22 Thread Thomas Girod
If your code is exactly what you've copy-pasted, then you are not testing against an empty string but a "one blank space" string ... I've just tried with : while line != "": and it works very well. -- http://mail.python.org/mailman/listinfo/python-list