oopkeywordconceptual

Difference between 'this' and 'self' in programming languages


In some languages, like Python, we use self, but in other languages such as Java, we use this.

Is there any special reason for this difference in name for the same function?


Solution

  • There is nothing special about the name self. It's the name preferred by convention by Pythonistas.

    The same goes for Java this, nothing special, just the name chosen by convention.