What does built-in class attribute __bases__ do in Python?

PythonServer Side ProgrammingProgramming

This built-in class attribute when called prints the tuple of base classes of a class object.

The following code shows how the __bases__ works. B is a child class of the parent/base class A.

Example

class A(object): pass
class B(A): pass
b = B()
print B.__bases__

Output

This gives the output

(<class '__main__.A'>,)
raja
Published on 12-Jan-2018 14:19:33
Advertisements