raise or not to raise [Newbie]
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sun Feb 4 16:26:28 EST 2007
Jacol a écrit :
> I understand that author generated exception and than extracted the name of
> function from the exeption. But is any sens in using exeptions service if
> we have smthing simpler: just print for example? In my opinion no, it
> doesn't make sens.
You're of course right. Exceptions are mainly a way of handling
'exceptional' conditions without cluttering the source code with error
code checking. The canonical use case is:
try:
some_call_that_may_raise(args)
except SomeException, e:
try_to_solve_the_problem()
The nice thing with exceptions (compared to 'manual' error handling) is
that you can choose where you want to handle the problem without having
to pass back error code/error message all along the call stack...
More information about the Python-list
mailing list