RecursionError

Built-in ExceptionPython 2.0+Intermediate

Raised when the maximum recursion depth is exceeded

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching RecursionError
try:
    def f(): f()
f()
except RecursionError as e:
    print(f"Caught RecursionError: {e}")
    print(f"Type: {type(e).__name__}")

RecursionError is raised when raised when the maximum recursion depth is exceeded. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore