No Do while/repeat until looping construct in python?
marshall
marshall at spamhole.com
Thu Mar 13 02:58:18 EST 2003
Alex Martelli <aleax at aleax.it> wrote:
>
> The general case of loop, known as "N times and a half", is:
>
> while True:
> <precode>
> if <sometest>: break
> <postcode>
>
> You appear to think (like the designers of some other languages)
> that the special case of <postcode> being empty has such enormous
> importance as to warrant making the language richer and more
> complicated to cover it.
>
This is so nicely and concisely stated but I had to "discover" it
myself. It sure would be handy to have a collection of these idioms.
The cookbook is great but it doesn't have the _almost_ obvious such as
the above.
"Colin Brown" <cbrown at metservice.com> wrote:
>
> Others have explained the Python way to do this, fine.
>
> I think this points out deficiencies of the documentation.
>
> The repeat .. until construct is familiar to those of us that have come
> from other languages and it would not hurt for the docs to show the
> standard Python idiom.
Agreed. I have no complaint about the documentation but a handy list
of python slang would be great - especially for list comprehensions
which always give me pause.
Marshall
More information about the Python-list
mailing list