Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...classmethod", cls, y foo = classmethod(foo) C.foo(1) c = C() c.foo(1) Both the call C.foo(1) and the call c.foo(1) end up calling foo() with two arguments, and print "classmethod __main__.C 1". The first argument of foo() is implied, and it is the class, even if the method was invoked via an instance. Now let's continue the example: class D(C): pass D.foo(1) d = D() d.foo(1) This prints "classmethod __main__.D 1" both ti...
...classmethod", cls, y foo = classmethod(foo) C.foo(1) c = C() c.foo(1) Both the call C.foo(1) and the call c.foo(1) end up calling foo() with two arguments, and print "classmethod __main__.C 1". The first argument of foo() is implied, and it is the class, even if the method was invoked via an instance. Now let's continue the example: class D(C): pass D.foo(1) d = D() d.foo(1) This prints "classmethod __main__.D 1" both times; in other words, the class pass...
If you didn't find what you need, try your search in the Python language documentation.