The rap against "while True:" loops

Mensanator mensanator at aol.com
Wed Oct 14 21:02:21 EDT 2009


On Oct 14, 6:08�pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> 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.

Does anyone actually use those things?

>
> Do you know how to proof-read your writing before hitting send?

Yeah. And I missed it. Maybe because my laptop has a few
broken columns of pixels.

> If not,
> please learn. A spell checker may help.

Not with Google.

> 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?

Conclusion based on false premise.

> Either way, there's no call
> for you to be snarky when people call you on stupid typos.

I suppose this wasn't snarky:

> >>        Uhm... that it isn't valid in any language having English
> >> influence upon it's keywords...

> Your mistake
> could happen to anyone, but it was still *your* mistake.

No, it wasn't. You should learn the difference between
an error and a mistake. There's nothing to be learned from
pointing out a typo. Whereas a mistake, such as using
"their" in place of "there" should be pointed out so
as to prevent future occurences.

>
> [...]
>
> > 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.

It can be.

>
> > 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.

And no one is forcing the OP to stop using "while True"
even if it is not considered Best Practice.

> You can write Pascal in any language you like.

My experience with Pascal is it tended to produce
bullet-proof code. The lessons learned from Pascal
can only make my Python programs better.

> > --
> Steven




More information about the Python-list mailing list