Python Object-oriented (self-Learning Python series notes-2) (not updated regularly)

Source: Internet
Author: User

L Instantiate operations directly with = , such as p=people ()

L for attributes, preceded by two underscore __ indicates the property of the private

L define the method with the DEF keyword, define the method in the class at least one parameter, if you use self as the argument, it must be the first argument, for self, with C + + or This is similar in Java , and when the method is called with an object, the first parameter of the object is passed to the self

L built-in methods in a class

N The constructor method __init__ (self,....) initializes the object when it is generated and does not require an explicit call

N destructor method __delf__ (self_) is called when the object is disposed, supports overloading

L class Properties and instance Properties

N class properties are common to all instance objects, which can be found directly through the class, People.name, of course p.name (p is an instance of class people)

N

Python Object-oriented (self-Learning Python series notes-2) (not updated regularly)

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.