A class method receives the class as an implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:
class C: @classmethod def f(cls, arg1, arg2): ...
The @classmethod form is a function decorator – see Function definitions for details.
A class method can be called either on the class (such as C.f()) or on an instance (such as C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.
Class methods are different than C++ or Java static methods. If you want those, see staticmethod() in this section. For more information on class methods, see The standard type hierarchy.
Changed in version 3.9: Class methods can now wrap other descriptors such as property().
Changed in version 3.10: Class methods now inherit the method attributes (__module__, __name__, __qualname__, __doc__ and __annotations__) and have a new __wrapped__ attribute.
Deprecated since version 3.11, removed in version 3.13: Class methods can no longer wrap other descriptors such as property().