The rap against "while True:" loops

Grant Edwards invalid at invalid.invalid
Mon Oct 12 16:51:52 CEST 2009

On 2009-10-12, Gabriel Genellina <gagsl-py2 at> wrote:

>> my_prissy_little_indicator_variable = true
>> while (my_prissy_little_indicator_variable){
>>     <body>
>> }
>> isn't satisfying because it doesn't guard the <body> with any
>> assurance that the loop invariant will be true before you enter into
>> that block of code.
> I think you meant the other way; the above is the simplest loop case, with  
> the test at the start.

Except the test at the start is meaningless when it comes to
reading the code and troubleshooting.  What counts are
assignments to my_prissy_little_indicator_variable inside the
loop.  And those aren't really any easier to spot that "break"

Grant Edwards                   grante             Yow! I want to read my new
                                  at               poem about pork brains and
                                 outer space ...

More information about the Python-list mailing list