【问题标题】:How to recover the inheritance of a class without the class object of python如何在没有python的类对象的情况下恢复类的继承
【发布时间】: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


【解决方案1】:

哎呀!对不起,我忘了写“大家好” 所以,大家好

【讨论】:

    猜你喜欢
    • 2015-11-25
    • 1970-01-01
    • 2018-07-08
    • 1970-01-01
    • 2017-05-29
    • 1970-01-01
    • 2015-05-17
    • 1970-01-01
    • 2010-12-24
    相关资源
    最近更新 更多