Normally, executing a Python program requires typing python <program>.py. However, it is possible to make Python programs self-executing so they don't require typing python as the calling command.
Making scripts executable
How to do it...
- On *NIX systems, putting #!/usr/bin/env python as the first line of a program allows the program to be executable by referencing the location of Python on the user's PATH. Of course, this assumes Python is on the PATH; if not, then the program will have to be invoked like normal.
- After this has been added to the program, the file itself needs to be modified to make it executable, that is, $ chmod +x <program>.py.
- If you are using a terminal program that displays...