Self

What is Self?

Definition

  • self is a conventional name for the first parameter of instance methods in a class.

  • It refers to the instance of the class on which the method is being called.

  • In other words, self represents the current object.

Why is it needed?

Python uses self to allow methods to access and modify the attributes and other methods of the object they belong to.

Updated on