RuntimeWarning

Built-in ExceptionPython 2.0+Intermediate

Warning about suspicious runtime behavior

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching RuntimeWarning
try:
    import warnings; warnings.warn("runtime issue", RuntimeWarning)
except RuntimeWarning as e:
    print(f"Caught RuntimeWarning: {e}")
    print(f"Type: {type(e).__name__}")

RuntimeWarning is raised when warning about suspicious runtime behavior. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore