How to break out of two nested for loops?

Donn Cave donn at
Thu Jan 24 13:18:25 EST 2002

Quoth Gareth.McCaughan at (Gareth McCaughan):
| Very true. But for most of us (so I conjecture, anyway) that's
| a relatively small part of the programming we do. I don't think
| it's terrible if someone prefers, on stylistic grounds, to use
| exceptions only (1) for truly exceptional situations and (2) as
| a handy building block for higher-level things which one can use
| without seeing the exceptions.

I hate circular discussions.  To break directly out of two nested
for loops, we have exceptions.  If the only reason not to use them
is purely stylistic - that is, we're unable to account for it in a
practical way - it seems to me that the issue is resolved.  We have
what we need, any time we want it.

| (But wasn't the discussion about whether using exceptions
| that way isn't in fact confusing? Isn't that more than a
| stylistic matter? Yes and no. What's confusing depends on
| what you're used to. It's reasonable not to be used to a
| heavily exception-based style even if you're writing Python,
| and in that case using exceptions for normal control flow
| will confuse you, and in that case you should avoid doing it.
| <0.5 wink>)

I take that as parody, but there's some rationale for selectivity
when you take on a programming language.  If you don't want or
need the more obscure features, that's excellent as far as I'm
concerned, we need more people like that.  But a core language
feature like exceptions is kind of a must, you can't sensibly opt
out.  What's left really is attitude.  I guess everyone has one.

	Donn Cave, donn at

More information about the Python-list mailing list