Appendix B. Running Programs

If you have a program open in IDLE’s file editor, running it is a simple matter of pressing F5 or selecting the Run▸Run Module menu item. This is an easy way to run programs while writing them, but opening IDLE to run your finished programs can be a burden. There are more convenient ways to execute Python scripts.

Shebang Line

The first line of all your Python programs should be a shebang line, which tells your computer that you want Python to execute this program. The shebang line begins with #!, but the rest depends on your operating system.

  • On Windows, the shebang line is #! python3.

  • On OS X, the shebang line is #! /usr/bin/env python3.

  • On Linux, the shebang line is #! /usr/bin/python3.

You will be able to run Python ...

Get Automate the Boring Stuff with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.