python-Object-oriented

Source: Internet
Author: User

Process-oriented: functional, C program and other object-oriented programming: C++,java,python Class and Object: Class: Is the abstraction of things, such as human, Ball object: Is an example of the class, such as football, basketball example shows: Ball can be the characteristics of the ball and behavior of the abstract, Then you can instantiate a real sphere. The main idea of object-oriented is: encapsulation, inheritance, polymorphic class definition (encapsulation): Classes combine the required variables and functions into a structure that encapsulates Class A (object) classes: Class Name: member Variable-property member Function-method Example:
 #  !/usr/bin/env python  class   People (object): Color  =  " yellow    " def   info (self):  print   " hello world!      " print   " i am a%s   "% Self.color ren  =  people () Ren.info ()  
The Info function (method) defined here Specifies the self parameter (the class itself), which means that the property of the class people is passed in, so that We can use the self. property directly inside the function to call here defines a class named people, which defines the member variable color, and defines the method info, the following ren = people () and so on people the instantiated object, We directly use this object to invoke the methods and properties of the class.

python-Object-oriented

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.