its a constructor like in C++. In c++ compiler will auto-detect the respective object of constructor. But in python, the self is nothing but the class instance, the python compiler will need the self (nothing but instance) to know for which instance the constructor is called, so self is passed to init(). Self is an instance of a class and we can access the instance variable of a class.