Object-oriented Python

Source: Internet
Author: User

Python is a dynamic object-oriented statement that focuses on several key concepts of object-oriented:

Class: is an abstract template that encapsulates class properties and methods (all of which can be done through the properties and methods of the Class).

Example: The specific object created by the class, allocating memory.

Inheritance: The most primitive is object, creating a class can inherit from the parent class can also be primitive creation (object), the subclass inherits all the properties and methods of the parent class, and has a new feature.

Polymorphic: Instances of subclasses have both the attributes of the subclass and the attributes of the parent class, if the parent class and subclass have the same method, then the parent class's method is hidden only the method of the subclass, judging what type the instance belongs to with type (instance) or Isinstance (instance, type) To determine if the instance has attributes that can be used with Dir (object), GetAttr ()/hasattr ()/setattr () are used to obtain, determine, or set the properties of the object.

Private and Special properties: There are 2 underlined properties and methods on both sides of the __xx__ that represent special properties and methods; __xx means that private variables cannot be changed externally, but the instance. _ Class name. _ variables can also be changed.

Object-oriented Python

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.