Comparison with False - something I don't understand

Mark Wooding mdw at distorted.org.uk
Thu Dec 2 11:35:08 EST 2010


Harishankar <v.harishankar at gmail.com> writes:

> There are some reasons why I hate exceptions but that is a different 
> topic. However, in short I can say that personally:
>
> 1. I hate try blocks which add complexity to the code when none is 
> needed. Try blocks make code much more unreadable in my view and I use it 
> only for the built-in exceptions when absolutely needed.

Very little code actually needs `try' blocks.

> 2. I prefer the less irksome True or False to do error checking.
> Exceptions seem too heavyweight for simple problems.

Just write simple programs as if errors never happen; if an exception is
raised, the program prints a vaguely useful message and exits.

Besides, this complaint is incoherent.  One needs at least as much
structure to check an error code as to catch an exception.

> 3. Philosophically I think exception handling is the wrong approach to 
> error management.

There are better ways to handle errors than Python's exception system.
Passing error codes around manually is most definitely not one of them.

(One of the main reasons I ditched Perl in favour of Python is the
former's insistence on returning error codes for I/O and system calls.)

-- [mdw]



More information about the Python-list mailing list