No Do while/repeat until looping construct in python?

Greg Ewing (using news.cis.dfn.de) me at privacy.net
Fri Mar 14 05:09:06 CET 2003


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.

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

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

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list