Built-in Exceptions

RuntimeError — exception class

A runtime failure not covered by a more specific category. Some operations reject changes while iteration is in progress; use the exception details to understand the state rather than catch every runtime failure indiscriminately. Catch RuntimeError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
RuntimeError

Return Value

type

The class object RuntimeError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
data={"a":1}iterator=iter(data)data["b"]=2try:    next(iterator)except RuntimeError as error:    print(type(error).__name__)
Python Reference