11, ' Classmethod ', the modifier corresponding to the function does not need to instantiate, do not need the self parameter, but the first parameter needs to be a CLS parameter representing its own class, you can invoke the properties of the class, the method of the class, instantiate the object, and so on.
Class Classmethod (object) | Method Classmethod (function) | | Convert a function to is a class method. # Convert a function into a class method | | A class method receives the class as implicit first argument,
A class method that receives the class as an implicit parameter | Just like an instance method receives the instance.
Just like an instance method receives an Instance object | To declare a class method with this idiom: | | Class C: | @classmethod | def f (CLS, arg1, Arg2, ...): | ... | | It can called either on the class (e.g. C.F ()) or in an instance | (e.g. C (). f ()). The instance is ignored except for its class.
You can call the F function with a class object, or you can invoke an F function on an instance object. If A class method is called for a derived class, the derived class | Object is passed as the implied first argument. | | Class methods is different than C + + or Java static methods. | If you want those, see the Staticmethod builtin. | | Methods defined here: | | __get__ (self, instance, owner,/) | Return an attribute of instance, which is of type owner. | | __init__ (self,/, *args, **kwargs) | Initialize self. See Help (Type Self) for accurate signature. | | __new__ (*args, **kwargs) from Builtins.type | Create and return a new object. See Help (type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | | __func__ | | __isabstractmethod__
Python __builtins__ Classmethod class (11)