3 AnswersNew Answer
1) if you're on linux/mac, you have to change file permissions (chmod) to make it executable, then add the so-called shebang line at the start of your file, e.g.: #!/usr/bin/python3 You'll most likely also have to look up how to set the PATH variable on your system to enable python. 2) on windows, you create a shortcut to your python.exe, then edit it in order to append the path to your filename.py. I recommend looking it up if the concept isn't clear to you, since it's hard to explain without screenshots/video. 3) alternatively, use this from cmd/terminal to create an executable: pyinstaller filename.py -F note that -F creates a single file instead of a folder containing multiple files. you can also append "-i filename.ico" to give it an icon. for further information, I recommend the pyinstaller documentation. Note: option #3 will create an application that runs on any computer, even if python isn't installed. the other options obviously require python installed on your system.
U can set keyboard short cut, if u are using vsc u can find it in settings , for others i didn't tried.
You can't do this unless you do one of the following: Compile your python code to machine readable format. or Write an bash script to run the program with the help of the python interpreter.