Hardware Reference
In-Depth Information
to understand at a glance. It also makes it easy to spot so-called syntax errors caused by for-
getting to put an end-quote in a print command or forgetting to comment out a remark.
For this short example, syntax highlighting isn't necessary—but in larger programs, it can be
an invaluable tool for inding errors.
Figure 11-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 ile 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 ilename (not .txt ) when you save it. his exten-
sion indicates that the ile contains Python code—although Python is clever enough to run
the program even if it's saved with a diferent ile extension.
How you run the ile 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. his
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 11-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.
Search WWH ::




Custom Search