__bases__

A class attribute holding the tuple of the class's direct parent classes.

In more detail

__bases__ lists only the direct parents, in the order the class statement gives them, and a class with no listed parent has (object,). Classes also carry __name__, their name as a string, and __module__, the name of the module that defined them, which is '__main__' for the running script. __mro__ is the full search order, the class first and object last.

Example

class A: pass
class B(A): pass
print(B.__bases__, B.__module__)   # (<class '__main__.A'>,) __main__

Related terms

Taught in

References

Certification courses