A Constructor is a special type of method which is used to initialize the object of the class.In c++ and java ,the constructor is the same name as its class.But in python,it is different .Hence we use __init__() as a special method to simulates the constructor of the class.This special method is called when the object of the class is created.
- The __init__() method accepts the self keyword as a first argument which is used to access the methods or attributes of the class.
- We can pass the any number of arguments at the time of object creation according to definition of __init__() method.
- The constructors are mainly used to initialize the class attributes.
- In python,every class must have a constructor even it may be a default constructor.