Python3 Object Orientation
Python has been an object-oriented language since its inception, and because of this, it's easy to create a class and object in Python. In this chapter we will detail Python's object-oriented programming.
If you haven't touched an object-oriented programming language before, you may need to understand some basic features of an object-oriented language and form a basic object-oriented concept in your mind, which will help you learn Python more easily. Object-Oriented Programming.
Next, let's take a brief look at some of the basic features of the following objects.
Introduction to Object-Oriented Technology
- Class: is used to describe a collection of objects with the same properties and methods. It defines the properties and methods that are common to every object in the collection. An object is an instance of a class.
- Method: The function defined in the 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 usually not used as instance variables.
- Data members: Class variables or instance variables are used to process related data for a class and its instance objects.
- Method rewriting: If the method inherited from the parent class does not meet the needs of the subclass, you can rewrite it. This process is called override of the method, also known as the weight of the method. write.
- Local variables: Variables defined in methods that only apply to classes of the current instance.
- Instance variables: In a class declaration, attributes are represented by variables. Such variables are called instance variables and are declared inside the class declaration but outside of the other member methods of the class.
- Inheritance: A derived class inherits the fields and methods of the base class. Inheritance also allows objects of a derived class to be treated as a base class object. For example, there is a design in which a Dog type object is derived from the Animal class, which simulates an "is-a" relationship (example, Dog is an Animal).
- Instantiate: Create an instance of a class, a concrete object of the class.
- Object: An instance of a data structure defined by a class. An object consists of two data members (class variables and instance variables) and methods.
Compared to other programming languages, Python adds class mechanisms without adding new syntax and semantics.
Classes in Python provide all the basic functionality of object-oriented programming: the inheritance mechanism of a class allows multiple base classes, and the derived class can override any method in the base class, and methods can call methods of the same name in the base class.
Objects can contain any number and type of data.