Extension of while syntax

Chris Angelico rosuav at gmail.com
Fri Dec 12 02:38:42 EST 2014


On Fri, Dec 12, 2014 at 6:10 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> You could deduplicate it by shifting the condition:
>>
>> while True:
>>     value = get_some_value()
>>     if value not in undesired_values: break
>>
>> But I'm not sure how common this idiom actually is.
>
> Extremely common, and not only in Python.

Something like it is certainly common, but to justify dedicated
syntax, the pure form has to be so amazingly common as to merit it. As
soon as you modify the pure form in any way, you need the statement
form, for full flexibility.

ChrisA



More information about the Python-list mailing list