[Python-Dev] PEP 3142: Add a "while" clause to generator expressions

Cameron Simpson cs at zip.com.au
Thu Jan 22 01:40:10 CET 2009

On 21Jan2009 14:02, Tres Seaver <tseaver at palladion.com> wrote:
| Vitor Bosshard wrote:
| > BTW, there is already an "until" keyword in python, it's called "while not" ;)
| 'until' is used at least in some languages (Pascal, Modula*, maybe Ada?)
| for a "terminate at bottom" loop (one guaranteed to run at least once):
|  in such cases, the predicate has the negative sense.

This is a particular flavour of "do ... while" which just happens
to read a little better in English. It does sometimes bother me that
Python doesn't have do...while when I find my self replicating the loop
bottom above the loop.

Back at uni we had to implement a small language in our compilers class
and the lecturer had specified a proper generic while loop, thus:

  while invariant

I think the keywords were better than above, but it neatly handled the
fact that the while-test must often be preceeded by some setup that
would be replicated at the loop bottom in Python and many other languages:

  while test-invariant
    do stuff

of which the bare while... and converse do...while loops are particular

Cameron Simpson <cs at zip.com.au> DoD#743

Why doesn't DOS ever say EXCELLENT command or filename?

More information about the Python-Dev mailing list