All variables defined on the class level in Python are considered static
class Example:
Variable = 2 # static variable
print Example.Variable # prints 2 (static variable)
# Access through an instance
instance = Example()
print instance.Variable # still 2 (ordinary variable)
# Change within an instance
instance.Variable = 3 #(ordinary variable)
print instance.Variable # 3 (ordinary variable)
print Example.Variable # 2 (static variable)
# Change through Class
Example.Variable = 5 #(static variable)
print instance.Variable # 3 (ordinary variable)
print Example.Variable # 5 (static variable)
You can have two different variables in your class under the same name (one static and one ordinary).
Don't be confused.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…