Python Self Variable
'self' is a default variable in python that contains the memory address of the instance of the current class. So, we can use 'self' to refer to all the instance variables and instance methods in python programming.
When an instance to the class is created, the instance name contains the memory location of the instance. This memory location is internally passed to 'self'.
1. The 'self' variable is used as first parameter in the constructor as:
2. 'self' can be used as first parameter in the instance methods as:
Here, talk() is instance method as it acts on the instance variables. If this method wants to act on the instance variables, it should know the memory location of the instance variables. That memory location is by default available to the talk() method through 'self'.