- ‘str’ is for users, while ‘reper’ is for debugging itself on the interactive console
- “self.count” indicates that this is related to an instance that is, count for each instance
5.例如下图中的count - don’t add “init” to things that are not related to instances, and don’t add self before them
- write it in the class ,call it with the class name
- delete a book with del()
- when del() is excecuted, the def_del_(self) is executed automatically
- class_defined functions can be called either by the name of the class or by an instantiated name
- for functions defined under class, if the values are called by instantiation and modified, the values invoked by class names will not be affected
- if you define an instance-independent function in a class, you can define a function without “self” in parentheses,
- the definition method instantiation name in the first screenshot can not be invoked, in the second figure below an interpreter is added to instantiate the name to be invoked
- designing a function to change age over time
- you can add a modifier in the class to make the class an attribute, and then call the modifier to define the function of the attribute
- can’t assign and delete “age”
25.summary
1.using object-oriented thought to write area code for circle finding
2.“@property" you can use functions as attributes.
1.class inheritance. for example below
the programer inheritanced class employee
“super()” refers to the base class or superclass
3.there is a working in the base class and a working in the later defined class this is called polymorphism
5.in addition to “super()”, it can be inherited in the following way using"class name. init(self,’’’’’’)",
this approach prevents confusion when inheriting multiple base classes
6.what is polymorphism?
answer:
different instances of the same type have different response capabilities to the same message
specifically, for wxample, for the information of work the programmer is writing code, while the security guard is maintaining order such a different response to the same message is polymorphism
7.the parameters of the incoming class can be a class, a dictionary, a list(this way the code can be correlated)