My understanding of Python object-oriented

Source: Internet
Author: User

First, Introduction

OO Programming---Object oriented programming, short: OOP, is a programming idea. OOP treats objects as a basic unit of a program, an object that contains functions for data and manipulating data. The appearance of object-oriented has greatly improved the efficiency of programming, and the reusability of programming is increased.

Python's Key object-oriented terminology:

1. Polymorphism (polymorphism): A function has multiple representations

2. Inherited (inheritance) subkeys inherit some of the functionality of the parent

3. Encapsulation (encapsulation) encapsulates functions or functions that need to be reused to facilitate direct invocation by other programs

4, class: A set of objects with the same data or method

5. Object: Object is a concrete case of a class

6, instantiation: is an object case of the implementation of the word

7. Identity: Each object's case requires a tag that uniquely identifies the case

8. Instance properties: An object is a collection of a set of properties

9, Case method: All Access or update an instance of an object one or more properties of the collection of functions.

10. Class Properties: Attributes that belong to all objects in a class.

11. Class Method:

II. classes and objects in Python

1 classPerson (object):2     def __init__(self,name):3Self.name =name4         Print "------>create:", name5     defSay_name (self):6         Print "My name is%s"%Self.name7 8P1 = Person ("GF1")9P2 = person ("GF2")Ten  One P1.say_name () AP2.say_name ()

Output Result:

1 ------>create:gf12 ------>create:gf23 is GF1  4 is GF2

The above procedures are understood as follows:

1, constructs a class, and initializes,

Third, the inheritance in Python

Iv. methods and member variables

My understanding of Python object-oriented

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.