How does isinstance() function work in Python?

PythonServer Side ProgrammingProgramming

We can derive a class from multiple parent classes as follows −

class A:        # define your class A .....
class B:         # define your class B .....
class C(A, B):   # subclass of A and B .....

We can use isinstance() function to check the relationships of two classes and instances.

  • The

  • isinstance(obj, Class)
  •  boolean function returns true if obj is an instance of class Class or is an instance of a subclass of Class

raja
Published on 16-Jan-2018 11:49:50
Advertisements