Python __builtins__ Classmethod class (11)

Source: Internet
Author: User
Tags instance method

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.