Python feature note (1): python feature note
1. constructor and destructor
1. python has constructor and destructor, which are the same as other languages. If the subclass needs to use the constructor of the parent class, it needs to be explicitly called in the constructor of the subclass. If the subclass has its own constructor, the constructor of the parent class is not automatically called. However, for sub-classes without constructors, the constructor of the parent class is automatically inherited, by default, child classes inherit the constructor of the first parent class of multiple parent classes. Note: Generally, the subclass should inherit all attributes and methods of the parent class. You can understand the constructor In the subclass as overwrite the constructor of the parent class.
2. The Destructor is called only when del is called, just like other speech. Display call
Ii. Heavy Load and coverage
Python does not have the concept of overload. You cannot use multiple functions with the same name as a class to implement overload based on the number of parameters or different parameter names. In python, functions with the same name always overwrite the previous function by default, which is not convenient, but it increases readability and comprehensibility. I think python is not overloaded because python is a dynamic language. Since the parameters are only determined at runtime, the overload should be meaningless for python; second, python does not allow missing parameters, which makes overloading meaningless for python. Note: in c #, you can write a virtual method in the parent class, and then use override in the subclass to reload the method. when calling the virtual method, the overwritten method is actually called.
Iii. Language type
There is no doubt that python is a dynamic strong-type language. If it is static, all I have seen is static in the list. The value passes a value (a new memory value is assigned), and the pointer passes a pointer to the memory, which is easy to understand.
Iv. Polymorphism
In simple terms, polymorphism is the multiple forms or States of a class. Python does not support polymorphism. Generally, subclasses are used to inherit the parent class and re-function. This is actually another object.