If you mean the "redo last" operation, which I believe is the default key binding for this function, then you can use this: (note that you'll have to include bl_info and register and unregister functions as in the code snippet below )
import bpy
class redo_last_operator(bpy.types.Operator):
bl_idname = "screen.redo_last_operator"
bl_label = "redo last"
bl_options = {'REGISTER', 'UNDO'}
def execute(self,context):
bpy.ops.screen.redo_last()
return {'FINISHED'}
Please note that importing this as an add-on will only add the operator to Blender, not add a Button to any panel. You can do that yourself, however, by creating a panel for it or adding it to a Panel yourself. The following code will create a panel as well:
import bpy
bl_info = {
"version": (1, 0),
"blender": (2, 75, 0),
"name": "Redo Last Operator",
"description": """Creates an operator for the redo last menu""" ,
"category": "File",
"location": """""",
}
class redo_last_operator(bpy.types.Operator):
# this class is meant only for destroying data blocks of a certain type, very powerful but very dangerous
bl_idname = "screen.redo_last_operator"
bl_label = "redo last"
bl_options = {'REGISTER', 'UNDO'}
def execute(self,context):
bpy.ops.screen.redo_last()
return {'FINISHED'}
class redo_last_operator_panel(bpy.types.Panel):
bl_label="redo last"
bl_idname="redo_last_operator"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category='Addons'
def draw(self,context):
self.layout.operator(redo_last_operator.bl_idname)
def register():
bpy.utils.register_class(redo_last_operator)
bpy.utils.register_class(redo_last_operator_panel)
def unregister():
bpy.utils.unregister_class(redo_last_operator)
bpy.utils.unregister_class(redo_last_operator_panel)
if __name__ == "__main__":
register()
If, on the other hand, you meant another operation, you can use the same code and still bind it to the button by replacing the code under execute().