No Do while/repeat until looping construct in python?

Lars W lw at hot-shot.com
Thu Mar 13 05:24:24 CET 2003


Hello!

	Why is there no do-while looping construct in Python? 
It seems to me that such a feature is very useful. Consider the 
following pseduocode:

<code>
while i<j:
	<code>

Compared with an imaginary do-while loop like in C or Pascal:

do:
	<code>
	while i<j

Alternatively, the imaginary code could be written:

repeat:
	<code>
	until i>=j

<code> might be a large chunk of code which has to be run at
least once before the evaluation of "i<j" is made. But Python
forces you to write code on the first form. 

	I might be missing something, but do-while is indeed a
useful looping construct which users would benefit from using.


Regards
Lars
lw at hot-shot.com




More information about the Python-list mailing list