174. Exception Hierarchy and Inheritance
import inspect
for cls in inspect.getmro(Exception):
print(cls.__name__)
# Output:
# Exception
# BaseException
# objecttry:
x = 10 / 0
except ZeroDivisionError as e:
print(f"Caught an exception: {e}")Last updated