I\'ve been searching through SO for a while now trying to come up with an answer to this but due to my inexperience with programming I don\'t understand much of the document
Python scripts can be made directly executable, like shell scripts, by putting the python environment path in the top of the script file.
#!/usr/bin/env python3.5
The Python installer automatically associates .py files with python.exe so that a double-click on a Python file will run it as a script. The extension can also be .pyw, in that case, the console window that normally appears is suppressed.
Detailed description also for linux is here.