No Do while/repeat until looping construct in python?

Alex Martelli aleax at aleax.it
Thu Mar 13 03:20:15 EST 2003


marshall wrote:
   ...
> I think that:
>   
>   if finished = 1: break
> 
> is just as good as:
>   
>   until finished = 1

Comparison is by == -- not by a single = -- doesn't affect your main
point but it should still be pointed out.


> and it beats having four different loop constructs with different
> keywords.

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.


comp.lang.python's volume has (I'd guess) a 20%-30% component
of "suggestions for alleged improvements to the Python language"
(in all flavors, most often "criticisms for alleged warts" and
the like) that invariably repeat discussions held dozens of
times over the years, add absolutely nothing, and whose only
result is making many old-time posters eventually drop the group
in sheer boredom -- Guido being an example, and far from the only
one.  Of course, it says a lot about the proponents/complainants
(and indirectly about the quality of the changes they propose or
whine or flame about) that they can't be bothered to use Google
for a while first to find out that their pet change has been
proposed a zillion times before and read up on the discussions.

If Python adopted even half of those interminably-repeated
requests for redundant feechurs, it would rapidly become as
rich, complicated and unwieldy as any other language you could
name, thereby losing one of its main sources of strength.


Alex





More information about the Python-list mailing list