The rap against "while True:" loops

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Oct 14 19:08:06 EDT 2009


On Wed, 14 Oct 2009 09:34:28 -0700, Mensanator wrote:

> On Oct 14, 2:19�am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
>> On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator
>> <mensana... at aol.com> declaimed the following in
>> gmane.comp.python.general:
>>
>> > You're not getting away that easy.
>>
>> > What's YOUR opinion of "whilr True"?
>>
>>        Uhm... that it isn't valid in any language having English
>> influence upon it's keywords...
> 
> Duh. You DO know that 'r' is next to 'e' on the keyboard?

Only on QWERTY keyboards. Not on Dvorak keyboards.

Do you know how to proof-read your writing before hitting send? If not, 
please learn. A spell checker may help. If you do know how, if you care 
so little for what you write that you can't be bothered, why should 
anyone care enough to read what you write? Either way, there's no call 
for you to be snarky when people call you on stupid typos. Your mistake 
could happen to anyone, but it was still *your* mistake.


[...]
> And what will that accomplish? The problem isn't using while True, it's
> the fact that you are escaping the loop. 

That's not a problem.


> Best Practice is to EXIT the loop properly, not escape from it.

A break does exit the loop properly. That's what it is for, it would be a 
pretty stupid language that had break exit the loop improperly.

Nobody is forcing you to use break. You can write Pascal in any language 
you like.



-- 
Steven



More information about the Python-list mailing list