Following is a code to define a class in python:
class Parent:
def __init__(self, fname, lname):
self.firstname = fname
self.lastname = lname
def view(self):
print(self.firstname , self.lastname)
class Child(Parent):
def __init__(self, fname, lname):
parent.__init__(self, fname, lname)
self.age = "20"
def view(self):
print(self.firstname , self.lastname , self.age)
ob = Child("Guido" , "Rossum")
ob.view()
__init__() function is called everytime a class is being used to make an object. In this Program, the child class init function overrides the parent class init function.