【发布时间】:2022-08-02 15:42:50
【问题描述】:
我正在使用 Python 开发一个项目,为此我需要检索没有 python 类对象 (<class \'object\'>) 的类的所有继承。 这是我的代码:
for h in inspect.getmro(obj):
if h != obj: # And if is <class \'object\'>. But `if h != obj or h.__name__ == \"object\"` doesn\'t work.
print(h)
dot.edge(title, h.__name__)
所以我想检索inspect.mro 但没有<class \'object\'>。
提前谢谢你, 亲切地,
-
你总是可以检索类对象,只是
type(obj).mro()是你想要的
标签: python-3.x