Static member variables (class variables) and normal member variables (instance variables)
Static member variables can only be obtained through the class name. Variable name, instance member variable, referenced by the instance. Variable name obtained.
When an instance assigns a value to a static member variable, the instance
Python is a dynamically typed language with no special flags distinguishing between static member variables and ordinary member variables
If you use the class name. Member variable that member variable is now a static member variable (class variable)
If you use an instance. member variable that member variable is now a normal member variable (instance variable)
When the value of an instance variable is initialized, the instance variable is not initialized when the object is constructed, but the instance variable is called by the object for the first time.
, copied from the value of the class variable at this time, and thereafter it does not affect each other.
Static methods, class methods, instance methods
An instance method, a normal method in a class, called by an instance
Class methods, methods that are decorated by @classmethod, class objects, and instances can call class methods
Static methods, methods that are decorated by @staticmethod, class objects and instances can call static methods, and static methods do not affect any instances
The difference between an instance method and a class method is that the first argument to the instance method is self (the instance itself), and the first parameter of the class method is the CLS (Class object province)
Note: The class object and the instance object here mean the type (class name)---classobj
Type (instance name)-instance
The concept of a personal sense of static is really not very good in python, because it is a dynamic language.
Static member variables, instance member variables, static methods, class methods, instance methods for Python