readline skips on line

Olivier Migeon olivier at
Tue Apr 18 09:41:25 CEST 2000

readline() actually reads a line and put the cursor at the beginning of the
next one each time you invoke it. And you invoke it in the loop.
I suggest:

while 1:
    if not mline : break
    print mline

> ----------------------------------Oo
> I got a part of a programm looking like this
> f=open('test.txt', 'r')
> while f.readline()!='':
>     print f.readline()
> print 'ready'
> but when it is runned, it wil print out the lines in the text file, but it
> skips all the the odd line, it only displays line 2,4,6,8,10 and further
> How can I solve this problem ?

 Sent via
 Before you buy.

More information about the Python-list mailing list