Using the While Loop

Mike Johnson ffp_randjohnson at yahoo.com
Sat Jun 16 19:11:18 CEST 2001


Hello all,

I don't see why this first code snippet won't work, but I can't find any
pointers in the documentation.

-------------------------------------- 
#!/usr/bin/python2.1

myfile = open ("/tmp/messages")

while line = myfile.readline():
    print line
--------------------------------------

But this works fine:
--------------------------------------
#!/usr/bin/python2.1

myfile = open ("/tmp/messages")

line = myfile.readline()
while line:
    print line
    line = myfile.readline()
--------------------------------------

Thanks for any help!

- Mike Johnson


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list