Exception as the primary error handling mechanism?
steven at REMOVE.THIS.cybersource.com.au
Wed Jan 6 05:49:52 CET 2010
On Tue, 05 Jan 2010 15:51:29 -0800, Phlip wrote:
> Why can't int('nonnumeric') return None?
It could do that, but it shouldn't, because returning magic values
instead of raising exceptions is usually a bad, bad idea.
> (A related question - why can't I just go 'if record = method(): use
> (record)'. Why extra lines just to trap and assign the variable before
> using it?)
Because that idiom is responsible for probably the most common error in C
of all, at least one of the most common errors. Thank goodness Python
forbids such a dangerous construct.
More information about the Python-list