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
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