readline skips on line

Joachim Kaeber kaeber at
Tue Apr 11 11:06:47 CEST 2000


try this:

f=open('test.txt', 'r')

while 1:
  if not line:
  print line

print "ready"

(you program uses odd lines for the test, even lines for output...)

Soundwave wrote:
> 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 ?

Joachim Kaeber (kaeber at (
GMD - Forschungszentrum Informationstechnik GmbH
    - German National Research Center for Information Technology
Schloss Birlinghoven                    email: kaeber at
D-53757 Sankt Augustin 1, Germany       phone: (+49 2241) 14-2546

More information about the Python-list mailing list