Python Programming – Special Functions in Python
The Python language provides two special functions, which can be used while using inheritance. These functions and their description is given in Table 11.1. The programming example for these functions is also given in Code 11.7., the output of which apparently makes clear the use of these functions.
|issubclass(child, parent)||Returns a boolean result; either true or false, true if the child is indeed a subclass of the superclass parent|
|isinstance(obj, Class)||Returns a boolean result; either true or false, true if obj is indeed an instance of Class or a subclass of Class|
Code: 11.7. Illustration of ininstance( ) and issubclass( ) functions.
|#Illustration of ininstance( ) and issubclass( ) functions
class student: #base class
class marks(student): #derived class
class result(marks): # new derived class