control structures (was "Re: Sins")

Evan Simpson evan at tokenexchange.com
Fri Jan 7 11:25:19 EST 2000


Emile van Sebille <emile at fenx.com> wrote in message
news:016a01bf57d3$cecb2900$01ffffc0 at worldnet.att.net...
> Doesn't this do that now? or is there some objection to this usage?

Three objections, none of them decisive:

1. Robustness: A typo in either the 'raise' or 'except' string will cause
your program to either die or jump to an unexpected location, possibly long
after you made the typo if the case is rare.  A typo in your argument or
parameter list will cause a runtime error; make sure you don't forget to
make them both lists or both tuples.  A typo in 'break' or 'continue' is
caught at compile time.

2. Clarity: When reading this code, how can I tell what is exceptional and
what is normal flow control?  I can't be sure that any given 'raise' is
meant to be handled locally without checking for a matching 'except'.

3. Efficiency/elegance:  Why invoke the exception machinery when a simple
JUMP will do? Why load up your runtime with these strings (which ought to be
nice and long and descriptive) when they're only needed as matching labels?

Cheers,

Evan @ 4-am





More information about the Python-list mailing list