while true: !!!

Simon Brunning SBrunning at trisystems.co.uk
Mon Dec 11 16:25:25 CET 2000


> From:	Jaroslav Gergic [SMTP:j_gergic at yahoo.com]
	(snip)
> Do you know better construction to avoid both - duplicate lines
> and horrible 'while 1' construction?
> 
> Something like:
> 
> while( "" != (line = fh.readline()) ):
>   ... do something ...
 
Unless the file is *really* big, I usually use:

for line in fh.readlines():
    do something with line

Simple, fast, and I've not personally had to process a file large enough
that this won't work.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list