Python Object-oriented

Source: Internet
Author: User
Class and object relationships:
Class: is a model
Object: An entity created by a model that can be seen and touched.
The difference between classes and objects
It's just a concept, it's a class.
The description is very specific , that is the object
3 Elements of a class
Class name, property, method
Mouse
Properties: Can glow, color, price, logo
Method (behavior/function/operation): Some special function keys, left button, right button
Cell phone
Properties: Color, size, brand, battery capacity
Method: Listen to songs, call, send text messages, play games, take pictures
Air conditioning
Properties: Height, size, color, brand, power
Method: Left pendulum and pendulum, switch, hot/cool

Abstract of class
Describe the scene in real life in class
Definition of Class
1. Class name recommended way to use hump
2. When defining the method, you need to write the self

Object
1. How to create an Object cat () opens up a memory space in memory to generate a Cat object
2.cat = Cat () uses a variable to point to this memory space
3.self: Who calls, Self is who.
4. A method in a class must have a parameter that does not necessarily self, who invokes it, and passes it in as the first argument.
__init__ Method:












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.