The rap against "while True:" loops

Jorgen Grahn grahn+nntp at snipabacken.se
Wed Oct 14 16:17:40 EDT 2009


On Wed, 2009-10-14, Marco Mariani wrote:
> Dennis Lee Bieber wrote:
>
>> 	One thing to note is that "break" ONLY exits the innermost loop --
>> Ada adds the confusion that one could define a label on the loops, and
>> have the innermost use
>> 	exit outer_label [when condition]
>> 
>> 
>> 	THAT I find scary... Since you have to match the label name to
>> something that occurs somewhere prior to the "exit", and THEN have to
>> find the end of that loop.
>
> But we have exceptions. And I know somebody, in other languages, thinks 
> it's a Best Practice to avoid using exceptions for flow control.

A lot of C++ programmers think so, and Stroustrup himself says
"exceptions are for exceptional things" or something to that effect.
Is that what you're thinking of?

Thankfully, Stroustrup doesn't use the dreaded phrase "Best Practice",
which as far as I can tell is designed to shut down rational thought
in the audience.

> Thankfully, python programmers are less dogmatic, and use whatever makes 
> sense to use. I hope.

Calling it "dogmatic" is unfair.  C++ is very different from Python,
and has a different implementation of exceptions. You also tend to use
the language to solve a different set of problems.

That said, I still don't fully understand the rationale behind that
advice or rule ... so I'm willing to break it, and sometimes I do.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .



More information about the Python-list mailing list