I have two sets of Operators. The first set, lets call it A, produce data. The second set, lets call it B, needs to read this data. What possibilities do I have to store my data from set A, so it is accessable for the ones from B?

Additional info:

  • The type of the data is a dictionary
  • It is not neccessary to store it in the blender file to make it persistend for later use
  • When Operators from A are called multiple times, the data shall be overwritten, so the Operarators from B always gets the latest data

2 Answers 2


A simple way is to use a global variable, although I don't recommend to make use of the global keyword on a dict directly. I suggest to use a class instead:

class G:

class OperatorA(...): ...
    G.your_dict = {"foo": "bar"}

class OperatorB(...): ...

You may replace pass with class variable declarations if B might try to access it before A sets it:

class G:
    your_dict = {"default": None}

If the data is really related to let's say OperatorA, you may also use that class instead of G. Inside of a method in OperatorA, you can either refer to the class via the explicit name, or via self.__class__.

  • 1
    $\begingroup$ Where should I instantiate the class G? $\endgroup$ Oct 15, 2014 at 18:02
  • 1
    $\begingroup$ Nowhere, you use the class itself, not any instance of it. Declare it in the global scope. It will be like a singleton. Classes are first-class citizens, just like functions - you can reference them like any other object (int, float, dict, function, ...). $\endgroup$
    – CodeManX
    Oct 15, 2014 at 20:42

Another place you might store a dictionary is in the scene itself.

bpy.context.scene['mydataparams'] = {'value':1}

It will get stored with the blender file. Whether that's a good thing or a bad thing is up to you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.