On Tue, May 8, 2018 at 11:50 PM, Chris Angelico <ros...@gmail.com> wrote:
> On Wed, May 9, 2018 at 3:36 PM, Ian Kelly <ian.g.ke...@gmail.com> wrote:
>>
>> while True:
>>     if we_are_done():
>>         break
>>     # do some stuff
>>     ...
>>     if error_occurred():
>>         break
>> notify_user()
>>
>>
>> Fixed, using idiomatic Python and without needing to use assignment in
>> an expression.
>
> Why is it that "while True" is idiomatic Python for a non-infinite
> loop? Is it merely because Python currently has no other way to spell
> certain loops? Surely it would be more idiomatic to encode the loop's
> termination condition in the header, if it were possible.

In the case of the code above you're correct; the condition could be
moved directly into the while. The loop that I adapted first assigned
we_are_done() to flag and then asserted that flag would be checked
again later. I neglected to maintain this part when I rewrote it.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to