How to properly ignore exceptions

try:
    doSomething()
except Exception: 
    pass

or

try:
    doSomething()
except: 
    pass

The difference is that the second one will also catch KeyboardInterrupt, SystemExit and stuff like that, which are derived directly from BaseException, not Exception.

See documentation for details:

However, it is generally bad practice to catch every error – see Why is “except: pass” a bad programming practice?

Leave a Comment