检查模块可能会有所帮助,特别是getclasstree()函数:
inspect.getclasstree(inspect.getmro(Exception))
或者,您可以递归遍历
__subclasses__()继承树,如下所示:
def classtree(cls, indent=0): print '.' * indent, cls.__name__ for subcls in cls.__subclasses__(): classtree(subcls, indent + 3)classtree(baseException)
印刷品:
baseException... Exception...... StandardError......... TypeError......... importError............ ZipimportError......... EnvironmentError............ IOError............... ItimerError............ OSError......... EOFError......... RuntimeError............ NotImplementedError......... NameError............ UnboundLocalError......... AttributeError......... SyntaxError............ IndentationError............... TabError......... LookupError............ IndexError............ KeyError............ CodecRegistryError......... ValueError............ UnipreError............... UnipreEnpreError............... UnipreDepreError............... UnipreTranslateError......... AssertionError......... ArithmeticError............ FloatingPointError............ OverflowError............ ZeroDivisionError......... SystemError............ CodecRegistryError......... ReferenceError......... MemoryError......... BufferError...... StopIteration...... Warning......... UserWarning......... DeprecationWarning......... PendingDeprecationWarning......... SyntaxWarning......... RuntimeWarning......... FutureWarning......... importWarning......... UnipreWarning......... BytesWarning...... _OptionError... GeneratorExit... SystemExit... KeyboardInterrupt
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)