Python _ builtins _ classmethod class (11 ),

Source: Internet
Author: User

Python _ builtins _ classmethod class (11 ),

11. For 'classmethod', the modifier's function does not need to be instantiated and the self parameter is not required. However, the first parameter must be the cls parameter representing its own class and can be used to call class attributes, class methods, instantiated objects, etc.

Class classmethod (object) | classmethod (function)-> method | Convert a function to be a class method. # converting A function into A class method | A class method when es the class as implicit first argument,
A class method. the receiving Class is used as an implicit parameter. | just like an instance method when es the instance.
Just like an instance method that receives an instance object | To declare a class method, use this idiom: | class C: | @ classmethod | def f (cls, arg1, arg2 ,...): |... | It can be called either on the class (e.g. c. f () or on an instance | (e.g. C (). f ()). the instance is ignored before t for its class.
You can call the f function using a class object or 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 are 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 _ | _ isactmethod __

 

Related Article

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.