Exception Handling Practices / Patterns

MRAB python at mrabarnett.plus.com
Sat Aug 24 12:32:39 EDT 2013


On 24/08/2013 11:27, Steven D'Aprano wrote:
> On Fri, 23 Aug 2013 22:25:55 -0700, snarf wrote:
[snip]
>> * Using
>> Exception is typically a bad. More specific the better.
>
> Yes, you should always try to catch the specific exceptions you care
> about:
>
>
> # Best
> except ValueError, OverflowError, ZeroDivisionError:
>
That should be:

except (ValueError, OverflowError, ZeroDivisionError):

>
> # Not so good
> except Exception:
>
>
> # Worst
> except:
>
[snip]




More information about the Python-list mailing list