[Python-Dev] PEP 315 - do while
fuzzyman at voidspace.org.uk
Tue Oct 3 12:00:18 CEST 2006
Nick Coghlan wrote:
>Hans Polak wrote:
>>Ok, I see your point. Really, I've read more about Python than worked with
>>it, so I'm out of my league here.
>>Can I combine your suggestion with mine and come up with the following:
>> <setup code>
>> <loop body>
>> while <condition>
>> <loop completion code>
>In my example, the 3 sections (<setup code>, <loop body> and <loop completion
>code> are all optional. A basic do-while loop would look like this:
> <setup code>
> while <condition>
>(That is, <setup code> is still repeated each time around the loop - it's
>called that because it is run before the loop evaluated condition is evaluated)
This looks good.
The current idiom works fine, but looks unnatural :
Would a 'while' outside of a 'do' block (but without the colon) then be
a syntax error ?
'do:' would just be syntactic sugar for 'while True:' I guess.
More information about the Python-Dev