Brief Analysis of object-oriented python

Source: Internet
Author: User

Brief Analysis of object-oriented python
_ Author _ = 'xiaobo' Python object-oriented brief analysis. To download the attachment, change the suffix. py, use "notepad ++" to open this document. "alt + 0" folds the function and makes it easy to see that everything in python is an object. In fact, the theoretical knowledge of object-oriented programming is quite understandable. To put it bluntly, it is just a bunch of nouns. In this way, the meaning of each noun represents and the relationship between them can be easily solved. Basic Terms of python Object-Oriented Programming: Class, object, method, and attribute. Relationships between classes and objects: classes are abstract objects, and objects are class instantiation. A class does not represent a specific thing, but an object represents a specific thing. Intuitively speaking, a bad person refers to a group of people. So you are a bad guy, because you have some characteristics of the bad guys. The bad guys are a class, and you are an object in the class. However, in actual programming, classes are not so well divided and need to be used more. Class and Object-Defined variables are called attributes. The class-Defined variables are called class attributes. The object-Defined variables are called methods in the object property class ): is the action conclusion of the object: Common Use Cases of the object = Attribute + method class, the object with the same attributes and methods is classified as a class: So the class is often used in: 1. Multiple methods share the same variables. 2. dynamically create objects with the same attributes. Three major features of the class: Polymorphism means that the same operation can be performed on different objects, but they may present results in multiple forms. Inheritance: One of the main benefits of object-oriented programming is code reuse. One of the ways to achieve this reuse is through the Inheritance Mechanism, which can be simply understood as subclass inheriting the parent class. Encapsulation: A class encapsulates the required attributes and methods in a class. Multiple methods can share a group of variables, and multiple objects can be created through a template. Class Member: field (attribute): static field, dynamic field method: dynamic method (class function), static method, class method property: a variable for class and object, another prerequisite class for adding a modifier to a method must be a new class. 1. @ property 2 and @ method name. setter 3, @ method name. deleter, the access is in the form of a field (so it is also called an attribute, your own understanding) class member modifier: Add _ (two horizontal bars) before the attribute or method ), the attributes and methods are private and cannot be accessed directly. Referencing images of a great God gives you a more intuitive understanding of object orientation. Some of these terms are not the same. Don't worry about them.

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.