Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import inspect
- builtins = sys.modules["builtins"]
- for name in dir(builtins):
- v = getattr(builtins, name)
- if not inspect.isclass(v):
- continue
- if not issubclass(v, Exception):
- continue
- print(name, [subclass.__name__ for subclass in v.mro()])
- # -- stdout --------------------
- # >> ArithmeticError ['ArithmeticError', 'Exception', 'BaseException', 'object']
- # >> AssertionError ['AssertionError', 'Exception', 'BaseException', 'object']
- # >> AttributeError ['AttributeError', 'Exception', 'BaseException', 'object']
- # >> BlockingIOError ['BlockingIOError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> BrokenPipeError ['BrokenPipeError', 'ConnectionError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> BufferError ['BufferError', 'Exception', 'BaseException', 'object']
- # >> BytesWarning ['BytesWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> ChildProcessError ['ChildProcessError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> ConnectionAbortedError ['ConnectionAbortedError', 'ConnectionError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> ConnectionError ['ConnectionError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> ConnectionRefusedError ['ConnectionRefusedError', 'ConnectionError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> ConnectionResetError ['ConnectionResetError', 'ConnectionError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> DeprecationWarning ['DeprecationWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> EOFError ['EOFError', 'Exception', 'BaseException', 'object']
- # >> EnvironmentError ['OSError', 'Exception', 'BaseException', 'object']
- # >> Exception ['Exception', 'BaseException', 'object']
- # >> FileExistsError ['FileExistsError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> FileNotFoundError ['FileNotFoundError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> FloatingPointError ['FloatingPointError', 'ArithmeticError', 'Exception', 'BaseException', 'object']
- # >> FutureWarning ['FutureWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> IOError ['OSError', 'Exception', 'BaseException', 'object']
- # >> ImportError ['ImportError', 'Exception', 'BaseException', 'object']
- # >> ImportWarning ['ImportWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> IndentationError ['IndentationError', 'SyntaxError', 'Exception', 'BaseException', 'object']
- # >> IndexError ['IndexError', 'LookupError', 'Exception', 'BaseException', 'object']
- # >> InterruptedError ['InterruptedError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> IsADirectoryError ['IsADirectoryError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> KeyError ['KeyError', 'LookupError', 'Exception', 'BaseException', 'object']
- # >> LookupError ['LookupError', 'Exception', 'BaseException', 'object']
- # >> MemoryError ['MemoryError', 'Exception', 'BaseException', 'object']
- # >> ModuleNotFoundError ['ModuleNotFoundError', 'ImportError', 'Exception', 'BaseException', 'object']
- # >> NameError ['NameError', 'Exception', 'BaseException', 'object']
- # >> NotADirectoryError ['NotADirectoryError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> NotImplementedError ['NotImplementedError', 'RuntimeError', 'Exception', 'BaseException', 'object']
- # >> OSError ['OSError', 'Exception', 'BaseException', 'object']
- # >> OverflowError ['OverflowError', 'ArithmeticError', 'Exception', 'BaseException', 'object']
- # >> PendingDeprecationWarning ['PendingDeprecationWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> PermissionError ['PermissionError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> ProcessLookupError ['ProcessLookupError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> RecursionError ['RecursionError', 'RuntimeError', 'Exception', 'BaseException', 'object']
- # >> ReferenceError ['ReferenceError', 'Exception', 'BaseException', 'object']
- # >> ResourceWarning ['ResourceWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> RuntimeError ['RuntimeError', 'Exception', 'BaseException', 'object']
- # >> RuntimeWarning ['RuntimeWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> StopAsyncIteration ['StopAsyncIteration', 'Exception', 'BaseException', 'object']
- # >> StopIteration ['StopIteration', 'Exception', 'BaseException', 'object']
- # >> SyntaxError ['SyntaxError', 'Exception', 'BaseException', 'object']
- # >> SyntaxWarning ['SyntaxWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> SystemError ['SystemError', 'Exception', 'BaseException', 'object']
- # >> TabError ['TabError', 'IndentationError', 'SyntaxError', 'Exception', 'BaseException', 'object']
- # >> TimeoutError ['TimeoutError', 'OSError', 'Exception', 'BaseException', 'object']
- # >> TypeError ['TypeError', 'Exception', 'BaseException', 'object']
- # >> UnboundLocalError ['UnboundLocalError', 'NameError', 'Exception', 'BaseException', 'object']
- # >> UnicodeDecodeError ['UnicodeDecodeError', 'UnicodeError', 'ValueError', 'Exception', 'BaseException', 'object']
- # >> UnicodeEncodeError ['UnicodeEncodeError', 'UnicodeError', 'ValueError', 'Exception', 'BaseException', 'object']
- # >> UnicodeError ['UnicodeError', 'ValueError', 'Exception', 'BaseException', 'object']
- # >> UnicodeTranslateError ['UnicodeTranslateError', 'UnicodeError', 'ValueError', 'Exception', 'BaseException', 'object']
- # >> UnicodeWarning ['UnicodeWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> UserWarning ['UserWarning', 'Warning', 'Exception', 'BaseException', 'object']
- # >> ValueError ['ValueError', 'Exception', 'BaseException', 'object']
- # >> Warning ['Warning', 'Exception', 'BaseException', 'object']
- # >> ZeroDivisionError ['ZeroDivisionError', 'ArithmeticError', 'Exception', 'BaseException', 'object']
Add Comment
Please, Sign In to add comment