PEP-0315--Enhanced While Loop: An idea for an alternative syntax

Paul Rubin http
Fri Feb 20 04:19:09 EST 2004


Peter Maas <fpetermaas at netscape.net> writes:
> The do block is no safeguard against copy errors because it's optional.
> A comment saves the same purpose. Replace
> 
> do:
>      init()
> while cond():
>      body()
> 
> by
> 
> # init while
> init()
> while cond():
>      body()
> 

No, you don't understand.  The initialization is part of the loop.
That is, the replacement for the do loop is

  while 1:
    init()
    if not cond: break
    body()

> PEP-0315 shouldn't be added to Python.

I agree, but the reasoning has to go a bit further.



More information about the Python-list mailing list