Study notes (25): zero-base mastering Python entry to actual combat-class definition object, self points to itself (2)

Learn now: https://edu.csdn.net/course/play/26676/339579?utm_source=blogtoedu

Class details:

Class attributes and instance attributes

Class attributes are also called static attributes. Only through the class can be modified, the instance also has the class attribute, but the class attribute cannot be modified. Once a static property is created, no matter how many instances are created, the value of the changed property remains unchanged.

Class attributes, variables defined in the class.

You can use dir() to check the properties and methods of classes and instances.

Adding attributes to the instance does not affect the attributes of the original class.

Adding attributes to a class will affect the attributes of instances derived from the class.

The attribute value defined in the class can be overridden in the instance.

Instance.__dict__ Check the attributes in the instance.

The methods in the class, unless otherwise specified, all take self as the first parameter.

self refers to the current instance

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/m0_49939521/article/details/109118400