# How to use bl_label inside an operator?

How do I reference the bl_label inside operators? I want to know the name of the operator based on the bl_label to be precise.

• Hi. I hope you don't mind my edit. If you meant something else please edit the question and correct it. – Martin Z Jan 3 at 8:37
• @MartinZ it is a slippery slope to answer, and then edit question based on answer. Recommend asking, via comments, for clarification first. – batFINGER Jan 3 at 8:45
• It wasn't formed clearly. I believe this was the intended question and encouraged yarun can to correct me if I am wrong. You might be right though. I will try to keep this in mind. – Martin Z Jan 3 at 8:55

You define bl_label inside the operator's code as a variable so after that you can reference it as any other variable inside the operator. It would be self.bl_label:

import bpy

class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"

@classmethod
def poll(cls, context):
return True

def execute(self, context):
print(self.bl_label)
return {'FINISHED'}

def register():
bpy.utils.register_class(SimpleOperator)

def unregister():
bpy.utils.unregister_class(SimpleOperator)

if __name__ == "__main__":
register()

# test call
bpy.ops.object.simple_operator()