python - Does `try... except Exception as e` catch every possible exception? -


in python 2, exceptions can raised 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

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -