More Abstract:
7.1 The Magic of the object: 1, polymorphic: You can use the same action for objects of different classes.
2. Encapsulation: Work details of hidden objects in the external world.
3, Inheritance: The General class as the basis for the establishment of specialized class objects
7.1.1 polymorphism: means that even if you don't know what type of object the variable refers to, you can manipulate it, and it behaves differently depending on the type of object (or Class). You can let users make method calls to objects that do not know what the class is.
7.1.2 Encapsulation: Hides excess information from other areas in the global scope. You can use it directly without worrying about how the object is created.
7.1.3 Inheritance:
7.2 Classes and types:
What exactly is the 7.2.1 class:
7.2.2 Create your own class: The class statement creates its own namespace where the function is defined. Self is a reference to the object itself, without which the member method cannot access the object in which it operates on its attributes.
7.2.3 features, Functions, and methods:
Private: To make a method or feature private (inaccessible from outside), just precede its name with a double underline. In the internal definition of a class, all names beginning with an underscore are ' translated ' and preceded by a single underscore and a class name. If you do not need to use this method but want other objects to not access internal data, you can use a single underline.
7.2.4 class namespace: When defining a class, all code in the class statement executes the class namespace in a special namespace. This namespace can be accessed by all members within the class. The definition of a class is actually a block of code execution.
7.2.5 Specifies the superclass:
7.2.6 Investigation Inheritance: Built-in functions: Issubclass (C,B); isinstance (object,class); __class__
7.2. More than 7 superclass (multiple inheritance): If a method inherits from multiple superclass, the method in the first inherited class overrides the method in the inherited class.
7.2.8 interface and introspection:
Summary:
objects: Objects include attributes and methods. A method is a function stored inside an object. The difference between a (bound) method and other functions is that the method always takes the object as its first parameter, which is generally called self.
Class: A class represents a collection (or class of objects) of an object, and each object (instance) has a class. The primary task of a class is to define the method that it uses for its instances.
Polymorphism: You do not need to know which class the object belongs to to invoke the method.
Encapsulation: objects can hide their internal state.
Inheritance: A class can be a subclass of one or more classes. Subclasses inherit all methods from the superclass.
Interfaces and introspection:
Object-oriented design:
Basic Python Tutorial (7)