all Python 3Exceptionsexception
ArithmeticError
built-in exceptions
Base class for arithmetic errors: ZeroDivisionError, OverflowError, FloatingPointError.
Syntax
raise ArithmeticError
Catching the base class is rarely what you want — in practice only ZeroDivisionError ever surfaces here, so name it directly in your except. Its siblings are misleading: ordinary float arithmetic that goes too far yields inf rather than an error (1e308 * 10), OverflowError shows up only in narrow spots such as float exponentiation and math functions, and FloatingPointError is never raised by CPython itself.
Examples
try:
raise ArithmeticError
except ArithmeticError as e:
print(type(e).__name__) # → ArithmeticError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy