wrote:

> Coming from a background that exposed me to far too many languages, I
> find the latter two examples (i.e. use try/except) to be horrible
> solutions.  It's not a matter of light/heavy weight, it's a matter of
> using exceptions for normal loop flow control is a really bad idea.
> 1)  I think it's less clear why the loop works
> 2)  The possibility (in more complicated examples) that this could mask
> a real exception (if for example, your function

I'm waiting for the end of that sentence...

> 
> I recommend reading Effective Java (Bloch), specifically the beginning
> of the exceptions chapter, for more details why using exceptions to
> exit loops is a bad thing (and while the title is effective java, much
> of it is directly applicable to a lot of python code)

Can you paraphrase some of the arguments for those of us not fortunate 
enough to have a copy of the book? I've heard a lot of arguments against 
using exceptions, and most of those I have heard don't apply to Python.

Like it or not, Python uses exceptions for normal loop flow control. That's 
a fact of life, live with it: every normal termination of a for loop is an 
exception. Real exceptions don't get masked: for loops terminate with 
StopIteration, and they only catch StopIteration, so any other exception is 
propagated.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to