[Python-Dev] PEP 315 - do while

Hans Polak Hans.Polak at capgemini.com
Tue Oct 3 12:14:45 CEST 2006


Thanks for your reply Nick, and your support Michael. I'll leave the PEP
talk to you guys :)

Cheers,
Hans 

-----Original Message-----
From: Michael Foord [mailto:fuzzyman at gmail.com] On Behalf Of Fuzzyman
Sent: martes, 03 de octubre de 2006 12:00
To: Nick Coghlan
Cc: Hans Polak; python-dev at python.org
Subject: Re: [Python-Dev] PEP 315 - do while

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:
>>
>>      do:
>>          <setup code>
>>          <loop body>
>>          while <condition>
>>      else:
>>          <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:
>
>       do:
>           <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)
>  
>

+1

This looks good.

The current idiom works fine, but looks unnatural :

while True:
    if <condition>:
       break

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.

Michael Foord
http://www.voidspace.org.uk

>Cheers,
>Nick.
>
>  
>


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.



More information about the Python-Dev mailing list