dailyhack icon indicating copy to clipboard operation
dailyhack copied to clipboard

Python3 exception tree hierarchy quick reference

Open sashadev-sky opened this issue 4 years ago • 0 comments

def printExceptionsTree(ExceptionClass, level = 0):
    if level > 1:
        print("   |" * (level - 1), end="")
    if level > 0:
        print("   +---", end="")
 
    print(ExceptionClass.__name__)
    for subclass in ExceptionClass.__subclasses__():
        printExceptionsTree(subclass, level+1)

printExceptionsTree(BaseException)

sashadev-sky avatar Mar 23 '21 20:03 sashadev-sky