I understand from the question Difference between 'cls' and 'self' in Python classes? that cls
is used in class methods while self
is used in instance methods.
However, I used self
in class methods and it is still working fine.
For example,
class Test:
@classmethod
def hello(self, name):
print ('hello '+name)
Test.hello('Tom')
What exactly does cls
or self
do in class methods?