[Email protected] is a function modifier, which means that the next is a class method, and for the usual we see is called the instance method. The first parameter of the class method is CLS, and the first argument of the instance method is self, which represents an instance of the class.
2. The normal object method requires at least one self parameter, which represents the Class object instance
3. Class methods have the class variable CLS incoming, so that some related processing can be done with the CLS. And with subclass inheritance, when the class method is called, the passed-in class variable CLS is a subclass, not a parent class. For a class method, it can be called through a class, like C.F (), a bit like a static method in C + +, or it can be called through an instance of the class, like C (). f (), here C (), written so that it is an instance of the class.
So when we write the method of the class, if we want to pass 2 parameters, when we define the method in the class to write three to add a CLS or self where the CLS can point out the method with @classmethod, self can point out the unused @classmethod method
The @classmethod in Python