How to access properties of Python super classes e.g. via __class__.__dict__?

后端 未结 2 378
鱼传尺愫
鱼传尺愫 2020-12-19 04:21

How can I get all property names of a python class including those properties inherited from super classes?

class A(object):
  def getX(self         


        
2条回答
  •  情话喂你
    2020-12-19 04:56

    You can use dir():

    for attr_name in dir(B):
        attr = getattr(B, attr_name)
        if isinstance(attr, property):
            print attr
    

提交回复
热议问题