PEP 315: Enhanced While Loop
Marcus Alanen
marcus at infa.abo.fi
Mon May 5 17:43:34 EDT 2003
On Mon, 5 May 2003 15:54:58 -0400, rzed <Dick.Zantow at lexisnexis.com> wrote:
>Andrew says that this:
>
>> while <condition1>:
>> <code1>
>> and while <condition2>:
>> <code2>
>> and while <condition3>:
>> <code3>
>
>would be equivalent to this:
>
>>
>> while <condition1>:
>> <code1>
>> if not (<condition2>): break
>> <code2>
>> if not (<condition3>): break
>> <code3>
>>
>... which means that the first 'while' and the second do not mean the
>same thing. That's less than "obvious" (ergo, less than "Pythonic"?).
>If "while" does not imply a looping construct, why use the word?
while <condition1>:
<code1>
break unless <condition2>
<code2>
break unless <condition3>
<code3>
Too Perlish?-) But it does read rather good, in my humble opinion.
Even "break if not <condition>" could be a small readability improvement,
the eye ought to see the "break" word easier. Since list comprehensions
have an optional if part, why can't break?
>I'd still prefer to see an indention of the entire while block,
>though -- it seems more obvious:
>
>while <condition1>:
> <code1>
> and if <condition2>:
> <code2>
> and if <condition3>:
> <code3>
Not that much difference between it and the standard
"if not condition2: break" code.
Marcus
More information about the Python-list
mailing list