The rap against "while True:" loops

Rhodri James rhodri at wildebst.demon.co.uk
Wed Oct 14 19:04:36 EDT 2009


On Wed, 14 Oct 2009 02:26:17 +0100, Mensanator <mensanator at aol.com> wrote:

> On Oct 13, 5:38�pm, "Rhodri James" <rho... at wildebst.demon.co.uk>
> wrote:
>> On Tue, 13 Oct 2009 22:59:04 +0100, Mensanator <mensana... at aol.com>  
>> wrote:
>> > And I'm not saying John nor the OP should stop
>> > using what works for them. But there are certainly
>> > valid reasons for "don't use while True" to be
>> > on the "Best Practices" list.
>>
>> Unfortunately, some of them seem to be reasons from
>> my point of view to put "*do* use while True" on the
>> "Best Practices" list. �
>
> Really? Which ones?
>
>> Some of the constructs you
>> seem to like ring big alarm bells with me, because
>> I've found entirely too many bugs hidden by them.
>
> For example?

Well, this one's always popular:

done = False
while not done:
   do_stuff()
   done = worry_about_stuff()
   do_more_stuff_at_great_length()
   done = worry_about_more_stuff()
   and_so_on()

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list