Global keyboard shortcut to execute text editor script
If you are only going to re-executing this script when 3D View is open you might add the shortcut to 3D View (global). I propose a different shortcut as alt+p is for showing the 'clear parent' menu, but it's up to you.



At the end of this list..



generic_executor.py

# something to test with..
import bpy
import random

x = random.randint(-6, 6)
y = random.randint(-6, 6)
z = random.randint(-6, 6)

bpy.ops.mesh.primitive_cube_add(radius=1, location=(x, y, z))


operator.py

import bpy


class GlobalScriptRunner(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "view3d.global_script_runner"
    bl_label = "Global Script Runner"

    #@classmethod
    #def poll(cls, context):
    #    return context.active_object is not None

    def execute(self, context):
        print('i get called')
        textblock_name = 'generic_executor.py'
        textblock_as_string = bpy.data.texts[textblock_name].as_string()
        exec(textblock_as_string)
        return {'FINISHED'}


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


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


if __name__ == "__main__":
    register()


To wrap this into a reusable add-on requires more time than I have, but it's not the purpose of this answer. The benefit of having this as an addon would be that you could create a panel for 3dview in which you can type or select a textblock to be executed when the shortcut is triggered, rather than this hard coded suggestion, where it only executes a textblock named generic_executor.py



edit:

Here's something you could use as a starting point, it creates a panel in 3dview (right side panel) and allows you to pick a textblock. Whenever you trigger the operator view3d.global_script_runner , it would look at the name of the selected file and execute it.

https://gist.github.com/zeffii/2b488961226ee1ecefcf