If I have Python code
class A():
pass
class B():
pass
class C(A, B):
pass
and I have class C
, is there a way to iterat
The inspect module was a good start, use the getmro function:
Return a tuple of class cls’s base classes, including cls, in method resolution order. No class appears more than once in this tuple. ...
>>> class A: pass
>>> class B: pass
>>> class C(A, B): pass
>>> import inspect
>>> inspect.getmro(C)[1:]
(, )
The first element of the returned tuple is C
, you can just disregard it.