4 ms·
> Never use catch-all except: statements, or catch Exception or StandardError, unless you are re-raising the exception or in the outermost block in your thread
by plq 15y ago
> Never use catch-all except: statements, or catch Exception or StandardError, unless you are re-raising the exception or in the outermost block in your thread (and printing an error message). Python is very tolerant in this regard and except: will really catch everything including Python syntax errors. It is easy to hide real bugs using except:.
What kind of SyntaxErrors are cought by the except: handler? Not all, I presume:
try:
a b
except:
pass
This fails with SyntaxError on Python 2.7.2 on my machine.