Python learning "Nineth" Python object-oriented programming

Source: Internet
Author: User
Tags class definition

First, object-oriented understanding

Object-oriented programming--object oriented programming, short for OOP, is a programming idea. OOP takes objects as the basic unit of a program, and an object contains functions for data and manipulating data.

Python has been an object-oriented language since its inception, which is why it is easy to create a class and object in Python.

Object-oriented technology
    • class: used to describe a collection of objects that have the same properties and methods. It defines the properties and methods that are common to each object in the collection. An object is an instance of a class.
    • method: a function defined in a class.
    • Class variables: class variables are common throughout the instantiated object. Class variables are defined in the class and outside the body of the function. Class variables are not typically used as instance variables.
    • data members: class variables or instance variables are used to manipulate the data related to the class and its instance objects.
    • method Overrides: if the method inherited from the parent class does not meet the requirements of the subclass, it can be overridden, which is called the override of the method, also known as the override of the method.
    • instance variable: A variable defined in a method that acts only on the class of the current instance.
    • inheritance: A derived class (derived class) that inherits the fields and methods of the base class. Inheritance also allows the object of a derived class to be treated as a base class object. For example, there is a design where an object of type dog is derived from the animal class, which is the analog "is a (is-a)" Relationship (example, dog is a animal).
    • instantiation: Creates an instance of a class, the concrete object of the class.
    • method: a function defined in a class.
    • object: An instance of a data structure defined by a class. The object consists of two data members (class variables and instance variables) and methods.

The classes in Python provide all the basic functions of object-oriented programming: The inheritance mechanism of classes allows for multiple base classes, and derived classes can overwrite any method in the base class, and the method can be called in the base class with the same name.

Class definition
Class ClassName:    <statement-1>    ...    <statement-N>

  

Second, class and object

Python learning "Nineth" Python object-oriented programming

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.