No Do while/repeat until looping construct in python?

Piet van Oostrum piet at cs.uu.nl
Fri Mar 14 18:19:41 EST 2003


>>>>> "Greg Ewing (using news.cis.dfn.de)" <me at privacy.net> (GE) wrote:

GE> Alex Martelli wrote:
>> Yes.  Having a single loop construct as Knuth suggested many decades
>> ago, e.g.:
>> repeat:
>> <pre-code>
>> while <test>:
>> <post-code>
>> might be nicer syntax sugar than the current Python approach:
>> while True:
>> <pre-code>
>> if not <test>: break
>> <post-code>
>> but the syntax-sugar difference is small enough to make it no
>> big deal, anyway.

GE> I think it's a somewhat bigger deal than you make out,
GE> since it would bring the exit condition into a prominently
GE> visible place, instead of being buried and easy to miss
GE> at first glance.

GE> And this is *such* a common looping pattern that I really
GE> don't understand why *no* language I can remember seeing
GE> has explicit support for it.

Algol 68 had it:
while
        precode;
        test
do
        postcode
od
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl




More information about the Python-list mailing list