Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content


Constructor and Destructor in Python


In this lecture we will see that -

What is Constructer and Destructor ?

What is the life cycle of object ?

How to implement class and objects in Python ?


Constructors in Python


Class functions that begins with double underscore (__) are called special functions as their special meaning.


_init_(self) function - this special function gets called whenever a new object of the class is instantiated.


Life cycle of object in Python


Step 1 : Definition

Python defines its classes with keyword 'class' which is defined in Python interpretor.


Step 2 : Initialization

When an instance of the class is created, _init_ method defined in the class is called. It initializes the attributes for newly created class instance. A namespace is also allocated for object's instance variables.


Step 3 : Access and Manipulation

Methods defined in a class can be used for accessing and modifying the state of an object. This are accessors and manipulators respectively. A class instance is used to call this methods.


Step 4 : Destruction

Every object that's created needs to be destroyed. This is done with Python garbage collection (that is reference counting).


Example :

class Student:

"To get Student Information..."

SchoolName="K.S School"





print ("Value set...")

def displayStudentData(self):

print("Id : ",

print("Name : ",

print("Email: ",








O/P :

Value set...

Id : 1

Name : Nirmal

Email :

To get Student Information...




Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere