+ 1

python3 Object-Oriented Programming Class & Static Methods

please can someone explain the 11 row in this https://code.sololearn.com/cnaM8Hz4FOnr/#py

26th Jan 2020, 6:51 PM
Kaveesha Thilakarathna
Kaveesha Thilakarathna - avatar
1 Resposta
+ 1
When you call a method, this method somehow has to know what instance it is even working with. For this reason, we always pass 'self' with a method. It looks like this: instance.method() But internally what happens is: ThatClass.method(instance) Now with class methods, the class itself is passed to the method instead of the instance. We need that if we want to access data that's only known to the class, not the instances.
26th Jan 2020, 7:00 PM
HonFu
HonFu - avatar