The accepted answer is incorrect incomplete (at least for Python 3.6 and above).
By catching Exception
you catch most errors – basically all the errors that any module you use might throw.
By catching BaseException
, in addition to all the above exceptions, you also catch exceptions of the types SystemExit
, KeyboardInterrupt
, and GeneratorExit
.
By catching KeyboardInterrupt
, for example, you may stop your code from exiting after an initiated exit by the user (like pressing ^C
in the console, or stopping launched application on some interpreters). This could be a wanted behavior (for example – to log an exit), but should be used with extreme care!
In the above example, by catching BaseException
, you may cause your application to hang when you want it to exit.