Bart Kastermans <[EMAIL PROTECTED]> writes:

> Roy Smith <[EMAIL PROTECTED]> writes:
> > The defensive thing to do is catch exactly the exception you
> > expect to happen. In this case, that means IndexError.
> 
> And you do that by
> 
> except IndexError:
>    raise TheErrorYouNowWantToRaise

You only do that if you want to throw away important information, such
as the traceback associated with the original exception. Not very
friendly to debugging.

> And
> except IndexError, e:
> 
> if you want access to the exception as well.

Usually best if it can be achieved. Not least because the bare 'raise'
statement will re-raise the original exception, complete with all its
context.

-- 
 \         “If we don't believe in freedom of expression for people we |
  `\           despise, we don't believe in it at all.” —Noam Chomsky, |
_o__)                                                       1992-11-25 |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to