Static class variables in Python

A static variable is a variable that has been allocated statically , meaning that its lifetime is the entire run of the program. Static variables exist only in single instance per class and are not instantiated. In Python, variables declared inside the class definition, but not inside a method are class or static variables .
class MyClass: static_var = 2

You can access this static variable like the following:

class MyClass: static_var = 2 print (MyClass.static_var) #2 MyClass.static_var = 5 print ( MyClass.static_var ) #5