which methods of Python are used to determine the type of instance and inheritance?

Total Post:57

Points:285
 423  View(s)
Ratings:
Rate this:
  1. Post:57

    Points:285
    which methods of Python are used to determine the type of instance and inheritance?

    Built-in functions in Python that work with inheritance: 

    1- isinstance() – this method checks the type of instance. 

    eg. isinstance(myObj, int) – returns True only when myObj. class is int. 

    2-issubclass() – this method checks class inheritance 

    eg. ***issubclass(bool, int) – returns True because bool is a subclass of int. 

       ***issubclass(unicode, str) – returns False because unicode is not a subclass of str.

Answer