param.descendents#

param.descendents(class_: type, concrete: bool = False) list[type][source]#

Return a list of all descendent classes of a given class.

This function performs a breadth-first traversal of the class hierarchy, collecting all subclasses of class_. The result includes class_ itself and all of its subclasses. If concrete=True, abstract base classes are excluded from the result, including Parameterized abstract classes declared with __abstract = True.

Parameters:
  • class (type) – The base class whose descendants should be found.

  • concrete (bool, optional) –

    If True, exclude abstract classes from the result. Default is False.

    Added in version 2.3.0.

    Added to encourage users to use descendents() in favor of concrete_descendents() that clobbers classes sharing the same name.

Returns:

A list of descendent classes, ordered from the most base to the most derived.

Return type:

list[type]

Examples

>>> class A: pass
>>> class B(A): pass
>>> class C(A): pass
>>> class D(B): pass
>>> descendents(A)
[A, B, C, D]