Python and Flaming Thunder
Duncan Booth
duncan.booth at invalid.invalid
Wed May 28 09:52:34 EDT 2008
Dave Parker <daveparker at flamingthunder.com> wrote:
> Catch also gives you a
> single, uniform, syntactically unambiguous way to embed statements (or
> whole statement lists) into expressions -- without causing the
> syntactic problems of = statements in if statements or the obfuscation
> of question mark notation, etc. For example:
>
> If catch(set x to y+z.) < 0.1 then go to tinyanswer.
>
So what does this do exactly if the set throws an error? Is the error
message printed at the top level going to be telling you about the failed
addition or the failed comparison? Why do you need the catch anyway, if a
statement is just an expression why can't you just put the statement into
parentheses?
For that matter, is there any way to distinguish between different errors
and only catch particular ones? A bare except clause in Python is usually a
signal of bad code: when handling errors you only want the errors you have
anticipated, and want to be sure that any unexpected errors don't get
caught.
You have a great opportunity to avoid making some of the same mistakes that
Python is trying to get out of. For example as of Python 2.5
KeyboardInterrupt and SystemExit to longer inherit from Exception. That
means a bare except in Python no longer catches either of those: if you
want to handle either of these exceptions you have to be explicit about it.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list