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

Last updated:9/19/2020 6:20:25 PM

1 Answers

Prakash nidhi Verma
Prakash nidhi Verma

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.