Adding operators
Operators can be grouped into different files according to their purpose. For example, transform-related operators such as Elevate Objects, which we covered in Chapter 4, can be put into a file named ops_transform.py, while our first few operators, Create Type Collections, written in Chapter 3, can be put in an ops_collections.py file. All those classes would be then registered by __init__.py and, if needed, added to the add-on interface via relative import.
Another solution is creating one module for all the operators, which can be named operators.py. In this section, we will create an operators module for our add-on.
Writing the operators module
In the structured _addon folder, we will create the operators.py module. It will contain our operator class: we will reuse the Add Random Location operator from Chapter 5. Besides bpy, which is ubiquitous in Blender script, we will import the random module and use randint in the add_random_location function:
import...