0

I am able to get the members in a class file from the inspect methods in python but now I also need to fetch the complete list of the class tree, for e.g. from which it has been inherited. So how can this be done. I am trying it using this method but it throws error

the code is as follows

for name in inspect.getclasstree(a.Simpleclass):
    print "classes is " + name

please help me to resolve it.

icedwater
  • 4,701
  • 3
  • 35
  • 50

1 Answers1

1

inspect.getmro() should be what you need.

>>> class A: pass
>>> class B: pass
>>> class C(A, B): pass
>>> [c.__name__ for c in inspect.getmro(C)]
['C', 'A', 'B']
Demian Brecht
  • 21,135
  • 5
  • 42
  • 46