The basic object-oriented concept of Python reading notes

Source: Internet
Author: User

The main purpose of object-oriented is to improve the reuse of programs

OOP object-oriented Programming

Similar objects grouped into classes

Class Bird (object) # #括号中的object, when object in parentheses indicates that the class does not have a parent class (header))

Have_feather = True

way_of_reproduction = ' egg '

Summer = Bird ()

Print Summer.way_of_reproduction

Action

The first argument of a method must be self, whether or not it is used.

Sub-class

The category itself can be further subdivided into sub-classes

In OOP, we express the concept by inheriting inheritance.

Class Chicken (Bird)

Way_of_move = ' Wald '

POSSIBLE_IN_KFC = True

The basic object-oriented concept of Python reading notes

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.