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.

Answer from EZLearner on Stack Overflow
🌐
Python
docs.python.org › 3 › builtins › exceptions.html
Built-in Exceptions — Python 3.14.7 documentation
In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any excep...
Top answer
1 of 2
50

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.

2 of 2
39

Practically speaking, there is no difference between except: and except BaseException:, for any current Python release.

That's because you can't just raise any type of object as an exception. The raise statement explicitly disallows raising anything else:

[...] raise evaluates the first expression as the exception object. It must be either a subclass or an instance of BaseException.

Bold emphasis mine. This has not always been the case however, in older Python releases (2.4 and before) you could use strings as exceptions too.

The advantage then is that you get to have easy access to the caught exception. In order to be able to add as targetname, you must catch a specific class of exceptions, and only BaseException is going to do that.

You can still access the currently active exception by using sys.exc_info() though:

except:
    be = sys.exc_info()[1] 

Pick what you feel is more readable for your future self and for your colleagues.

🌐
Real Python
realpython.com › ref › builtin-exceptions › baseexception
BaseException | Python’s Built-in Exceptions – Real Python
In Python, BaseException is a built-in exception that serves as the base class for all exceptions.
🌐
DEV Community
dev.to › waylonwalker › dont-inherit-from-python-baseexception-heres-why-1p4d
Don't inherit from python BaseException, Here's why. - DEV Community
March 31, 2022 - Since things such as KeyboardInterrupt are created as an exception that inherits from BaseException, if you except BaseException you can no longer KeyboardInterrupt.
🌐
GeeksforGeeks
geeksforgeeks.org › python › built-exceptions-python
Python Built-in Exceptions - GeeksforGeeks
All other exceptions directly or indirectly inherit from it. While it is rarely used directly in code, it is important because it forms the foundation of Python’s error-handling system. Example: This example manually raises a BaseException and catches it to show how the root exception works.
Published: April 18, 2026
🌐
airbrake
docs.airbrake.io › home › blog › python › the python exception class hierarchy
The Python Exception Class Hierarchy - Airbrake Docs
November 2, 2017 - The reason for this naming convention ... Error in the name are, in fact, errors. The BaseException class is, as the name suggests, the base class for all built-in exceptions in Python....
🌐
W3Schools
w3schools.com › python › python_ref_exceptions.asp
Python Built-in Exceptions
The table below shows built-in exceptions that are usually raised in Python.
Find elsewhere
🌐
jd:/dev/blog
julien.danjou.info › home › blog › the definitive guide to python exceptions
The definitive guide to Python exceptions — jd:/dev/blog
August 11, 2016 - In Python, the base exception class is named BaseException. Being rarely used in any program or library, it ought to be considered as an implementation detail. But to discover how it’s implemented, you can go and read Objects/exceptions.c in the CPython source code.
🌐
SDSU
edoras.sdsu.edu › doc › Python-Docs-2.5 › lib › module-exceptions.html
2.3 Built-in Exceptions
September 19, 2006 - For string exceptions, the associated value itself will be stored in the variable named as the second argument of the except clause (if any). For class exceptions, that variable receives the exception instance. If the exception class is derived from the standard root class BaseException, the associated value is present as the exception instance's args attribute.
🌐
GitHub
github.com › rmotr-curriculum › advanced-python-programming-questions › issues › 16
what does mean "exceptions must derive from BaseException"? · Issue #16 · rmotr-curriculum/advanced-python-programming-questions
November 15, 2017 - tests.py:37: in is_valid raise "WARNING! Raises NameError" E TypeError: exceptions must derive from BaseException Assignment: http://learn.rmotr.com/python/advanced-python-programming/advanced-oop-inheritance/form-fields User code: class...
Author: rmotr-curriculum
🌐
Medium
zlliu.medium.com › 9-python-exception-things-i-regret-not-knowing-earlier-7bbdd0f4881f
9 Python Exception Things I Regret Not Knowing Earlier | by Liu Zuo Lin | Medium
September 7, 2024 - 9 Python Exception Things I Regret Not Knowing Earlier 1) The exception hierarchy Python has a number of built-in Exceptions that we might meet from time to time eg. ZeroDivisionError, KeyError …
🌐
GitHub
github.com › python › cpython › blob › main › Objects › exceptions.c
cpython/Objects/exceptions.c at main · python/cpython
.tp_vectorcall = BaseException_vectorcall, }; /* the CPython API expects exceptions to be (PyObject *) - both a hold-over · from the previous implementation and also allowing Python objects to be used · in the API */ PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException; ·
Author: python
🌐
LinkedIn
linkedin.com › pulse › advanced-exception-handling-python-understanding-atexit-moonhee-lee-ezwrc
Advanced Exception Handling in Python: Understanding BaseException, atexit, and Beyond
February 28, 2024 - BaseException sits at the top of Python's exception hierarchy, acting as the base class for all exceptions, including system-exiting exceptions and errors.
🌐
Python documentation
docs.python.org › 3 › tutorial › errors.html
8. Errors and Exceptions — Python 3.14.7 documentation
BaseException is the common base class of all exceptions. One of its subclasses, Exception, is the base class of all the non-fatal exceptions. Exceptions which are not subclasses of Exception are not typically handled, because they are used ...
🌐
Read the Docs
python.readthedocs.io › fr › latest › library › exceptions.html
5. Built-in Exceptions — documentation Python 3.7.0a0
In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived from that class (but not exception classes from which it is derived).
🌐
Real Python
realpython.com › python-exceptions
Python Exceptions: An Introduction – Real Python
March 18, 2026 - Python exceptions provide a mechanism for handling errors that occur during the execution of a program. Unlike syntax errors, which are detected by the parser, Python raises exceptions when an error occurs in syntactically correct code.
🌐
Real Python
realpython.com › ref › builtin-exceptions
Python’s Built-in Exceptions (Reference) – Real Python
AssertionError Occurs when an assert statement fails. AttributeError Occurs when you attempt to access a method or attribute that isn’t defined for the object in question. BaseException Serves as the base class for all exceptions.
🌐
Medium
medium.com › python-pandemonium › a-very-picky-except-in-python-d9b994bdf7f0
A very picky ‘except’ in Python
October 8, 2018 - That explains what happened with python2: He really tried to catch not ‘any of exceptions in a list’ but the list object itself. Nevertheless we can’t raise such a thing: >>> try: ... raise [IOError, ValueError] ... except [IOError, ValueError]: ... print "oh..." ... Traceback (most recent call last): File "<stdin>", line 2, in <module> TypeError: exceptions must be old-style classes or derived from BaseException...
🌐
Python.org
discuss.python.org › python help
Different behavior of `BaseException.with_traceback` in Python 3.11 vs 3.10? - Python Help - Discussions on Python.org
May 4, 2023 - Here is a short code example. I’m chaining function calls f, g, and eventually h where an exception is being raised. The traceback, as expected, shows the call to f (in ), then the call to g (in f), then the call…