This is mainly experimental stuff I’m doing right now. I wrote this script to take the names of blender operators and put them in a Python dictionary using the ops submodules as keys. I guess I was just kind of curious.
So I learned a few interesting things.
I wasn’t aware of the idea of fake modules and submodules until now.
There are these _bpy python modules which do the background work of registering scripts for you and other lower level tasks.
So here’s my tiny little script I just figured I’d share. If I can think of more to expand on this, I will. Feel free to fire comments and suggestions towards me.
import bpy import _bpy from collections import defaultdict def make_operator_dict(): submod_op_pairs = [entry.split("_OT_") for entry in _bpy.ops.dir()] submod_op_pairs = [(k.lower(), v) for k,v in submod_op_pairs] op_dict = defaultdict(list) for key, val in submod_op_pairs: op_dict[key].append(val) return op_dict if __name__ =='__main__': op_dict = make_operator_dict() for key in op_dict: print(" %s...... %d operators" % (key, len(op_dict[key]))) print(op_dict[key])