The name does not matter, but applying classmethod
decorator makes the method a class method. In such case the first argument is a class, not an instance.
Please take a look at the comparison of instance, class and static methods using the following code:
>>> class Test(object):
def instance_method(sth, x):
return sth, x
@classmethod
def class_method(sth, x):
return sth, x
@staticmethod
def static_method(x):
return x
>>> a = Test()
>>> a.instance_method('abc')
(<__main__.Test object at 0x0000000002C26D30>, 'abc')
>>> a.class_method('abc')
(<class '__main__.Test'>, 'abc')
>>> a.static_method('abc')
'abc'
By convention, when you are referring to the same instance, you name it self
. When you are referring to its class, you name it cls
. That is only a convention, but it is better to follow it for consistency.