do...while
Chris Barker
Chris.Barker at noaa.gov
Thu Jun 20 15:30:47 EDT 2002
"Michael P. Soulier" wrote:
> How do you people handle the lack of a do...while in Python?
> line = filehandle.readline()
> while len(line) > 5:
> line = filehandle.readline()
The most common idiom is:
while 1:
line = filehandle.readline()
if not len(line > 5):
break
do stuff....
I try to avoid "break" but is it is at the top of the loop, the meaning
is pretty clear.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Python-list
mailing list