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

Eric Smith eric at trueblade.com
Thu Jan 22 10:06:24 CET 2009


Terry Reedy wrote:
> 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

Indeed. This is the well known "loop and a half" problem.

Eric.


More information about the Python-Dev mailing list