Why is "while" ticking me off???

Alan Gauld alan.gauld at gssec.bt.co.uk
Fri Oct 6 11:13:41 EDT 2000


Thomas Gagne wrote:
> while line = fp.readline():
>     do something with 'line'
> 
> but that doesn't work because Python doesn't allow assignments 

correct, so at the expense of typing a line twice, do 
the assignment externally:

line = fp.readline()
while line:
   # do something wiyth line
   line = fp.readline()

Alan G.
-- 
=================================================
This post represents the views of the author 
and does not necessarily accurately represent 
the views of BT.



More information about the Python-list mailing list