Try/Except vs Exception handling

try:
  foo()
except:
  pass

or

try:
  foo()
except Exception:
  pass

Difference is that the first will catch everything including OsError, KeboardInterrupt, SystemExit which are derived from BaseException instead of Exception class.

More documentation for details:

try statement — http://docs.python.org/reference/compound_stmts.html#try
exceptions — http://docs.python.org/library/exceptions

Comments

Popular posts from this blog

Multiple repeat error when the regex has multiple wildcards in python re module

Weakref proxy is for instance only ...

To speed up accessing files on nfs shares on a ubuntu machine ...