Self is an instance or an object of a class. In python, this is explicitly included as the first parameter. This is not the case in java where it’s optional. It helps to differentiate between the methods and attributes of a class with local variables. The self variable in the lnit method refers to the newly created object. While in other methods, it refers to the object whose method was called.
Home What is self in Python