Python Classes and objects

Source: Internet
Author: User

1. Concepts of classes and objects:
The concept of class abstraction, which represents a class of things that have the same characteristics
The concept of object figurative, individual individual
. Class and object relationships:

-classes are summed up by object abstraction, and the process of summarizing classes by objects is called abstraction
-objects are implemented or implemented by a class, and the process of making an object from a class is called instantiation
For example: Animal is a class, then dog cat Pig. And so on is the instantiation of animals.
A dog is a class, then a pug. All kinds of dogs are examples of dogs.
In the. class, there are 2 contents in a class:
Content used to denote the characteristics of a thing, called a member property (variable)
Content used to denote the function of a thing, called a member method (function)

2. Basic implementation of the class:
Name of the. class file
. Compliance with variable naming conventions
. Using the Hump naming method
. There is one or more words composed
. direct connection between words
. Capitalize each word first letter
. How to declare a class:
. declaring a class with the class keyword
Content in A. Class consists of member properties and member methods, and other content is prohibited from appearing in classes such as Process control, looping statements, etc.
The syntax is correct, but it destroys the structure of the class.
. Define member properties use variable assignment operations, if a member has no value, you need to use None to assign a value (or an empty string?).

Python Classes and objects

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.