Name: Aniket Subhash Darade Subject: Python Programming Teacher: Tejashree Ma'Am Standard: Sy BSC It ROLL NO: 197032
Name: Aniket Subhash Darade Subject: Python Programming Teacher: Tejashree Ma'Am Standard: Sy BSC It ROLL NO: 197032
Example:
class example(object):
def __init__(self,intputs):
self.out = inputs
... instance = example(inputs)
Built_in class attributes
class Person(object):
def __init__(self, name):
self.name = name
def getName(self):
return self.name
def isEmployee(self):
return False
class Employee(Person):
def isEmployee(self):
return True
emp = Person("Geek1")
print(emp.getName(), emp.isEmployee())
emp = Employee("Geek2")
print(emp.getName(), emp.isEmployee())
output:
True
False
THERE ARE TWO INBUILT PYTHON
FUNCTION FOR INHERITANCE :
1. Isinstance()
2. Issubclass()
1. Isinstance()
This function is used to check the type of instance.
For example: isinstance(obj,int)
This function will return the true value if obj.class is of int type or some
class derived from the int.
2. Issubclass()
This function is used to check the class inheritance.
For example: issubclass(bool,int)
■ This function will return the true value if bool is a subclass of type
int.
Thank You