2.8.1.3 Constructor and Destructor
Python Programming
- Constructor: Constructor is a special type of function which is used to initialize the class variables. In Python the __init__() method is used to initialize an object's properties when it is created.
python
class Car:
def __init__(self , color):
self . color = color- Destructor: The __del__() method is called when an object is deleted. It is used for cleanup purposes.
python
class Car