Hardware Reference
In-Depth Information
Figure 12-2:
Syntax
highlighting
in IDLE
Before you run your program, save it as helloworld.py using the File menu. If you're
using IDLE, the file will be given the extension .py automatically. If you're using a text edi-
tor, be sure to type .py at the end of the filename (not .txt ) when you save it. This exten-
sion indicates that the file contains Python code—although Python is clever enough to run
the program even if it's saved with a different file extension.
How you run the file will depend on whether you're using IDLE or a text editor. In IDLE,
simply choose Run Module from the Run menu, or press the F5 key on the keyboard. This
will switch IDLE back to the Python shell window and run the program. You should then see
the message Hello, World! appear onscreen in blue (see Figure 12-3). If not, check your
syntax—in particular, check that you have quotation marks at both the beginning and end of
the message on the print line.
If you created the helloworld.py program in a text editor, you'll need to open a terminal
window from the Accessories menu on the desktop. If you saved the file anywhere except
your home directory, you'll also have to use the cd command to change to that directory (see
Chapter 3, “Linux System Administration”). Once you're in the right directory, you can run
your program by typing the following:
python helloworld.py
Search WWH ::




Custom Search