python - Does `try... except Exception as e` catch every possible exception? -
in python 2, exceptions can raise
d required inherit exception?
that is, following sufficient catch possible exception:
try: code() except exception e: pass
or need more general like
try: code() except: pass
with first variant you'll catch "all built-in, non-system-exiting exceptions" (https://docs.python.org/2/library/exceptions.html), , should catch user defined exceptions ("all user-defined exceptions should derived class").
for example, first variant not catch user-pressed control-c (keyboardinterrupt), second will.
Comments
Post a Comment