Bare Excepts

samwyse samwyse at gmail.com
Wed Dec 30 09:11:45 EST 2009


On Dec 30, 7:23 am, Jean-Michel Pichavant <jeanmic... at sequans.com>
wrote:

> Rule N°2:
> dont use BARE EXCEPT, or you'll piss off MRAB for good :o). Beside from
> kidding, don't use bare except.

I inherited some code that used bare excepts *everywhere*.  There were
about 4K lines of code, IIRC, and I think that they were more except
clauses than elses.  Eventually, I used sed to add a print_exc() after
each one, just so I could figure out what the expected exceptions
were.  It was so bad that I seriously considered writing a program
just to parse all the tracebacks from my instrumented version and then
revise the source code for me, but I didn't want to accidentally miss
any "real" errors.



More information about the Python-list mailing list