A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-January/085302.html below:

Add a "while" clause to generator expressions

[Python-Dev] PEP 3142: Add a "while" clause to generator expressions [Python-Dev] PEP 3142: Add a "while" clause to generator expressionsTerry Reedy tjreedy at udel.edu
Thu Jan 22 04:22:55 CET 2009
Cameron Simpson wrote:
>
> 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:
> 
>   loop:
>     suite
>   while invariant
>     suite
>   endloop

In Python, that is spelled

while True:
   suite
   if not invariant: break
   suite

> 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:
> 
>   setup-invariant-state
>   while test-invariant
>     do stuff
>     setup-invariant-state

Good Python programmers do not repeat the setup code like this.
See the proper say-it-once way above.

This discussion belongs back on Python ideas, where it began and should 
have stayed.

tjr

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4