about properties and methods in class classesdef __init__ (self, variable): A method that is automatically called when the class is defined as an objectdef __call__ (self, variable): This is to call the method of the class directly when the function is called, generally the object. Method () call, which is called by the object ()def __str__ (self, variable): This is a method that the object is directly printed by default call is usually a print (object) to usedef __getattr__ (self, variable): This is called when an object calls its properties, there is no error . Add this method to change the error to call the GetAttr methoddef __setattr__ (self, variable): This is the method that will be called when the object property is set. This method is easy to error, write a method to pay attention to the dead loop property: Use to define an attribute such as name at the end of the class, and then the name is "Properties" (Method 1, Method 2, Method 3, "comment") Method 1: Calling this property calls Method 1, which equals the Read property call Method 1Method 2: The method that is called when writing to this property 2 this method equals Write property Method 2Method 3: When you delete this property, Method 3 is called, which equals the Delete attribute Method 3
Learning Python on the road ....