Follow the development of Python in old boy education [Article 7]: Object-oriented 2, old boy python

Source: Internet
Author: User

Follow the development of Python in old boy education [Article 7]: Object-oriented 2, old boy python

Field

Static Field application:

Memory saving:

Generally, you can access your own fields.

Rule: common fields can only be accessed by objects, and static fields can be accessed by classes (object access is allowed ).

Static fields have been created when the code is loaded.

Common, static, and class methods

Singleton mode: class method.

All methods belong to the class:

1. A common method, at least one self, executes the object.

2. Static methods, arbitrary parameters, and class execution (Object execution is allowed ).

3. Class method, at least one cls, class execution (Object execution is allowed ).

Class member attributes

 

 

Attribute: method-based writing and field-based access.

Member Modifier

PRIVATE: only the members of the class can access it.

Note: special methods for accessing private fields (_ class name_xxx ).

Print (obj. _ Foo _ age)

Special Member

 

 

 

 

 

 

Isinstance and issubclass inherit super

 

Ordered dictionary Singleton Mode

The Singleton mode is used to create a single instance.

Exception Handling

 

 

 

Assertions

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.