Self In Class

Inside the class body self refers to the current class object.

It can be used to access / modify properties and call functions inside the class.

self is not a keyword, it's simply the name of the first parameter of a class function. It can have some other name but the naming convention suggests using 'self'.




  • At lines 17 and 18 values are set to the properties width and height.
  • At line 20 the printData function is called. self points to the class object.