Variables in Blender API operator classes

User defined operator classes, inherited from bpy.types.Operator, are static. Accordingly, only static variables can be defined in them.

Static variable sampleVar definition in SampleClass class:


defines a static variable sampleVar with a default value of 5.

Since at the time of operator executrion a temporary instance of its class creates with local copyes of the class variables. So getting the value of the desired class variable is possible from the current instance of the class:

or through the class itself:

Class instance exists only during operator execution, so setting class static variable value through the current instance is impossible. That case value stores only to the local instance variable sampleVar copy, not to the static class variable, and will be removed with current instance after operator completion. Therefore setting a value to static variable is possible only through an appeal of the class.

Accessing static class variables outside the class is possible via its classname: