do...while

Chris Barker Chris.Barker at noaa.gov
Fri Jun 21 15:53:02 EDT 2002


Bjorn Pettersen wrote:
> Doing a quick search over our C++ libraries (~900KLoc), "do {} while()"
> seems to be used in right around 3% of the loops (including while, for;
> excluding recursion).

I was surprised that it was used so rarely, but them I realized that in
C/C++, assignment returns a value, so you can do the equivalent of:

while line = file.readline():
	....

which is used a lot, but can't be done in Python. That's still not a
reason to add the construct, but it is a commonly occuring structure.

-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