21 Feb
2014
21 Feb
'14
7:18 p.m.
On Sat, 22 Feb 2014 02:12:04 +1100
Chris Angelico
Overbroad exception handling comes in two ways. One is simply catching Exception or BaseException when a narrower class would be better, and that's not addressed by this PEP (except insofar as it does not have a bare "except:" syntax, and so it forces you to at least be explicit about catching BaseException). The other is this:
try: f(x[i]) except IndexError: f(default)
Translating that into this form:
f(x[i] except IndexError: default)
means that an IndexError thrown inside f() will not be caught.
Thank you and Nick for the explanation. This is a good point. I'm still put off by the syntax, though, just like Brett. Regards Antoine.