python scripting - how to stop my modal operator code from getting the old data? i was working on a code to print this word (extruded) for every time i use extrude region tool 
bpy.ops.mesh.extrude_region_move

so i created this code 

import bpy

class ModalOperator(bpy.types.Operator):
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"

    def execute(self, context):
        print("This is the modal operator")
        return {'FINISHED'}

    def modal(self, context, event):
        if bpy.ops.mesh.extrude_region_move != None:
            print("extruded")



        return {'PASS_THROUGH'}




    def invoke(self, context, event):
        print("This is the invoker")

        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

bpy.utils.register_class(ModalOperator)

bpy.ops.object.modal_operator('INVOKE_DEFAULT')


but the problem is this line run for every extrude that happen before not only the new ones so how to fix it ?

the line to get the extrude events 

    if bpy.ops.mesh.extrude_region_move != None:
        print("extruded")



    return {'PASS_THROUGH'}
Look at context.active_operator

As long as there is a registered operator bpy.ops.mesh.extrude_region_move != None will always be true. bpy.ops.mesh.extrude_region_move
is a callable method, which will never be None

Could check the value of the active operator.  Script below prints to console if the extrude and move operator is the last operator called. It will keep printing (modally) until another operator is called.  Would need to add some logic, a class property perhaps, to make it notify only once.

import bpy

class ModalOperator(bpy.types.Operator):
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"
    #save_op = None

    def execute(self, context):
        print("This is the modal operator")
        return {'FINISHED'}

    def modal(self, context, event):
        active_op = context.active_operator
        idname = getattr(active_op, "bl_idname")
        if idname == "MESH_OT_extrude_region_move":
            print("extruded")
            # set some var here to run once and check equality
            # self.save_op = active_op

        return {'PASS_THROUGH'}

    def invoke(self, context, event):
        print("This is the invoker")

        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

bpy.utils.register_class(ModalOperator)

bpy.ops.object.modal_operator('INVOKE_DEFAULT')


could look at the index in window manager operators collection.
(py console code)

&gt;&gt;&gt; [o.bl_idname for o in C.window_manager.operators]
['OBJECT_OT_editmode_toggle', 'MESH_OT_extrude_region_move']


Get the transform constraint axis

&gt;&gt;&gt; op = C.window_manager.operators['MESH_OT_extrude_region_move']
&gt;&gt;&gt; op.macros['TRANSFORM_OT_translate'].properties['constraint_axis'].to_list()
[0, 0, 1]