Python object-oriented that's right.

Source: Internet
Author: User

Although Python is an interpreted language, it has been an object-oriented language since its inception, and it is an object for Python. Because of this, it is easy to create a class and object in Python, but if you are accustomed to writing a procedure or function, Python does not make a hard limit.

The object-oriented features of Python are as follows:

Packaging

The term object in object-oriented programming is basically a collection of data (attributes) and a series of methods that can access and manipulate the data. The traditional "program = data structure + algorithm" is encapsulated "masked" and simplified to "program = object + Message". An object is an instance of a class, and the abstraction of a class needs to be encapsulated. Encapsulation allows callers to use directly without worrying about how objects are built.

Inherited

Class Inheritance:

The direct feeling of inheriting is that this is a code of reuse behavior. Inheritance can be understood as the creation of a specialized class object based on a common class, and the subclass and its inherited parent class are is-a relationships.

Multiple inheritance:

Unlike C#,python, which supports multiple class inheritance (C # can inherit from more than one interface, but inherit from a class at most). Multiple inheritance mechanisms are sometimes useful, but it's easy to complicate things.

Polymorphic

Polymorphism means that the same action can be used on different objects, but they may present results in a variety of shapes. In Python, polymorphism is used when you do not know what the object is, but need to do something about it. The method is polymorphic and the operator is polymorphic.


Python object-oriented that's right.

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.