It seems to me that the last answer discusses the naming convention of the first parameter without explaining what it evaluates itself for what is known as a static method versus the usual method. take the following example:
class A(object): def x(self): print(self) @classmethod def y(self): print(self) a = A() b = A() c = A() print(ax()) print(bx()) print(cx()) print() print(ay()) print(by()) print(cy())
The conclusion is as follows:
<__main__.A object at 0x7fc95c4549d0> None <__main__.A object at 0x7fc95c454a10> None <__main__.A object at 0x7fc95c454a50> None () <class '__main__.A'> None <class '__main__.A'> None <class '__main__.A'> None
note that the x
method, called by three objects, gives different hexagonal addresses, which means that the self
object is bound to an instance. the y
method shows that self
actually refers to the class itself, and not to the instance. that is the difference.
source share