Inheritance: There are functions of the parent class, and after the subclass inherits
Inheritance is the object that writes the parent method directly to the subclass.
If you define a class that has many repetitive functions, you can define a repeating class as a parent class
Static methods: can be called without instantiation, and can not invoke variables and methods inside the class
Class method: Can be called without instantiation, or you can invoke variables and methods inside a class
xiaohei= ' hahaha '
@staticmethod #静态方法, no instantiation is required and can be used directly
def other ():
Print (' I am a static method ')
@classmethod #类方法 and do not need to be instantiated, you can use it directly
#类方法可以使用类变量和类方法
def class_fun (CLS):
Print (Cls.xiaohei)
Cls.get ()
========================= I'm a split line =============================
Noun Explanation:
Process oriented
Object-oriented programming encapsulates the functions that you wrote previously into a class
Class
When defining a class, the first letter of the class name is capitalized
If you use classes, you have to instantiate them first.
constructor function
When a class is instantiated, it automatically executes the constructor.
Variables inside the attribute class
The function inside the method class.
Self represents this class of objects.
Instance
Object
instance variables and class variables
Private functions
Private variables
Can only be used in the class, out of the class can not be used.
Inherited
The parent class has all the functions and the variable quantum classes.
If you define a class that has a lot of repetitive functions, you can define these repeating classes as parent classes.
Packaging
Polymorphic Python does not support polymorphism
A method of multiple implementations.
instance method, which must be instantiated before it can be called
Property method You look like a property, actually a function, and you have to instantiate it to invoke
Class method
It is straightforward to use without instantiation, and it can be used with class variables and class methods.
#类方法, it doesn't need to be instantiated, it can be used directly. It's a static method advanced point
#它可以使用类变量和类方法.
Static methods
No need to instantiate the direct use, in fact, and the class has nothing to do with, is a common function
It's written in the class, and it doesn't use self, and it calls out the other functions inside the class.
Modifying the constructor of a parent class
Related nouns such as python-inheritance-