class BaseClass:
statement-1
statement-2
.....
.....
statement-n
class DerivedClass(BaseClass):
statement-1
statement-2
.....
.....
statement-n
The name BaseClassName must be defined in a scope containing the derived class definition. With all this said, we can implement our Person and Employee class is as following example :
>>> class Person:
def __init__(self, first, last):
self.firstname = first
self.lastname = last
def Name(self):
return self.firstname + " " + self.lastname
>>> class Employee(Person):
def __init__(self, first, last, staffnum):
Person.__init__(self,first, last)
self.staffnumber = staffnum
def GetEmployee(self):
return self.Name() + ", " + self.staffnumber
>>> x = Person("Ramana", "Chanti")
>>> y = Employee("Suresh", "Raja", "1017")
>>> print(x.Name())
Ramana Chanti
>>> print(y.GetEmployee())
Suresh Raja, 1017
>>>