News for hackers. Stuff that matters.
Re:Google's Python style guide by plq on Thursday April 19, 2012 @03:54AM (#3861873)
> 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.
Re:Google's Python style guide by mxey on Thursday April 19, 2012 @03:59AM (#3861883)
That code is never executed because it fails to parse. I think you can catch SyntaxError if you import a file with broken syntax.
Re:Google's Python style guide by grifaton on Thursday April 19, 2012 @04:19AM (#3861927)
This would catch a SyntaxError raised by eval().

For example,

    try:
        eval(".")
    except:
        pass