At the top of the family we have:
BaseExceptionThis is the super parent of all exceptions (errors) in Python.
Every other error comes from this.
BaseExceptionThese are special system-level exceptions (not used often by normal programmers):
SystemExit → Raised when sys.exit() is called (to exit program).
KeyboardInterrupt → Raised when you press Ctrl + C to stop program.
GeneratorExit → Raised when a generator is closed.
Exception → The main parent of all “normal” errors (like ValueError, TypeError).
👉 As a programmer, you usually handle Exception and its children, not the other three.
Exception (common ones)These are the errors you see every day:
Arithmetic Errors
ZeroDivisionError (divide by zero)
OverflowError (number too big)
FloatingPointError (rare floating-point issues)
Lookup Errors
IndexError (list index out of range)
KeyError (dict key missing)
Type and Value Errors
TypeError (wrong data type, e.g., "5" + 2)
ValueError (right type but wrong value, e.g., int("abc"))
Import Errors
ImportError (module can’t be imported)
ModuleNotFoundError (module doesn’t exist)
File and OS Errors
FileNotFoundError (file missing)
PermissionError (no access rights)
OSError (general system-related errors)
Others
AttributeError (attribute doesn’t exist)
NameError (variable not defined)
RuntimeError (general error during runtime)
NotImplementedError (something is not yet implemented)
Think of it like a family tree 👪:
BaseException → Great-Grandparent 👴
Exception → Parent 👨
TypeError, ValueError, ZeroDivisionError, FileNotFoundError… → Kids 👦👧
So whenever you write:
except Exception:
# handle error
👉 You’re catching all the kids (common errors) but not the great-grandparent (BaseException special ones like SystemExit, KeyboardInterrupt).
BaseException
├── SystemExit
├── KeyboardInterrupt
├── GeneratorExit
└── Exception
├── ArithmeticError
│ ├── ZeroDivisionError
│ ├── OverflowError
│ └── FloatingPointError
├── LookupError
│ ├── IndexError
│ └── KeyError
├── ImportError
│ └── ModuleNotFoundError
├── OSError
│ ├── FileNotFoundError
│ ├── PermissionError
│ └── TimeoutError
├── ValueError
│ └── UnicodeError
├── TypeError
├── AttributeError
├── NameError
├── RuntimeError
└── ...
✅ So, in short:
BaseException = All errors.
Exception = Normal errors you usually deal with.
Children of Exception = Specific everyday errors.