Comparison with False - something I don't understand

Harishankar v.harishankar at gmail.com
Sat Dec 4 12:07:45 EST 2010


> You appear to be suffering from the delusion that all exceptions must be
> caught and handled. This is far from being the case. But still, better
> to have your top-level code "littered with exception handlers" than to
> have your functions "littered with if statements".

Of course not. But going by the replies here, it appears that Python has 
made exceptions as the "norm" for error handling which is ironical 
considering the meaning of the word "exception". I find a bit cumbersome 
that exceptions are advocated for certain conditions which can be sanely 
worked around in the application's logic and even avoided, rather than 
waiting for them to get caught and providing an unsatisfactory result.

> 
> Quite often it's impossible for the function to know what needs to be
> done when a specific conditions arises, in which case (presumably) you
> have to return some error code and test for that ...

Not necessarily. I wasn't talking about low-level or built-in exceptions. 
I was talking about using exceptions in my programming where often the 
function is reasonably confident of the kind of errors it is likely to 
incur. I did not start this as a criticism of Python's exceptions as 
such. I just expressed my personal aversion to using them in my own code.

However, in my next project I have started using exceptions and will keep 
an open mind on how it turns out. So far it doesn't seem too bad.


> 
> regards
>  Steve





-- 
Harishankar (http://harishankar.org http://lawstudentscommunity.com)




More information about the Python-list mailing list