In Python, the @classmethod decorator defines a method that belongs to the class rather than a particular instance.
A class method receives the class itself as its first argument, conventionally named cls. It can therefore access or modify class-level data and is commonly called through either the class or an instance. A frequent use is an alternative constructor, such as a method that creates an object from a string, dictionary, or other representation.
The decorator is often confused with @staticmethod. A static method is also stored on the class, but it receives no automatic self or cls argument and behaves like a regular function placed inside the class namespace. By contrast, @property creates managed attribute access, while @abstractmethod marks a method that subclasses are expected to implement.
Python’s class-method design supports inheritance: when called through a subclass, cls refers to that subclass. This makes @classmethod especially useful for factory methods that should produce the appropriate derived type.