1. polymorphic
2. Static methods
3. Class methods
4. Attribute methods
5. The origin of the class
6. Reflection
7. Exception Handling
8.Socket Communication
When the class needs to inherit two, and the arguments for each class are different
you need to inherit one of the classes (for example:person) in the following way, passing arguments
call the method of the parent class . Person. Method Name
polymorphic Example
Multiple implementations of an interface
Static methods
@staticmethod
The class is no longer related to the class and cannot be called by Self. It's not necessary for self to write.
the only connection to the class is when the call is class to invoke the
Use For example :OS Toolkit
Class method
Property method
@property into a property call the direct method name does not add (), like a variable called
@eat. When the setter becomes a property call, it is impossible to pass arguments, which can be used to pass parameters in
into the d.eat= "QQQ" parameter, feeling similar to the Java overload,
Called when the value is assigned . there are @eat. Setter of the
@eat. Deleter Delete Properties
Two methods
Output results
in the class __call __ Method, you can trigger execution after the object ()
as follows:D is an object, plus () call will error, but add this method, you can call.
The __call __ method is performed .
Output
__dict__ View all members of a class or object
Use scenario: View, class, or instance properties after a project has been running for a period of time
When you print an instance, a string of memory addresses is normally output , and after you add this method to the class
You can return the results you want.
as follows: return the name parameter of the object
To manipulate objects like a dictionary
The second way to create a class
Type is the top class
First write the constructor, and then use the type to load these things in.
The origin of the class
The __new__ method is executed before the __init__ method is executed, and is a intit method called by the new method
Python Learning notes--Qi