+ 2
Self
what is self in classes. and why should self be the first parameter of every classes. and what is its importance. thank you
3 odpowiedzi
+ 10
See SoloLearn's Python course > Object oriented programming > Class, lesson 2:
'All methods must have self as their first it isn't explicitly passed, Python adds the self argument to the list for you; you do not need to include it when you call the methods. Within a method definition, self refers to the instance calling the method.'
+ 6
Tashi N explained it very well. self is like 'this' in other programming languages.
+ 1
Because self is the class itself, any class should access to itself