Comparison with False - something I don't understand

MRAB python at mrabarnett.plus.com
Thu Dec 2 12:57:33 EST 2010


On 02/12/2010 16:12, Tim Harig wrote:
> On 2010-12-02, Harishankar<v.harishankar at gmail.com>  wrote:
>> I understand that the error vs exception debate is quite a big one in the
>> programming community as a whole and I don't consider myself very
>
> Actually, I thought that debate was resolved years ago.  I cannot think of
> a single recently developed programming language that does not provide
> exception handling mechanisms because they have been proven more reliable.
>
>> Python. I do understand both sides of the issue. Exceptions seem to be
>> generally more reliable but I feel they add a lot of complexity
>> particular when a lot of code is placed in a try block.
>
> Lines of code is one measure of complexity.  Each line of code has a small
> chance of containing a bug.  The more lines of code that you have, then the
> more likely that one of them contains a bug.  Exceptions, by placing error
> handling code in fewer places, requires much fewer lines of code then
> requiring error handling code after each call that might produce an error
> condition.
>
> The operations of propogating an error up to the higher level logic of
> the program is another measure.  In languages without exception handling,
> careful planning is needed to pass error conditions up through the call
> stack until they reach a high enough level in the logic that decisions
> can be made about how to handle them.  Even further planning must be
> taken so that when the error condition reaches level where it needs to
> be handled, that enough information about the error is present to know
> exactly what went wrong so that it can figure out what to do about it.
> This usually involves using globals like errorno to pass out of band
> information about the error.  Sometimes you even need to know about how
> the error affect intermediate levels, did the intermediate code attempt
> to handle the condtion and fail?  The Openssl error handling system,
> that creates an error logging chain is an example of just how complex
> this can become.  You gain all of this functionality automatically
> through exception mechanisms; without all of the complexity.

When writing the C code for the new regex module I thought that it
would've been easier if I could've used exceptions to propagate errors
and unwind the stack, instead of having to return an error code which
had to be checked by the caller, and then have the caller explicitly
return an error code to /its/ caller.

Automatic garbage collection would also have been nice.

You don't realise how nice it is to have such things until you have to
go without them.



More information about the Python-list mailing list