Datasheet

Chapter 1: A Python Primer
2
The Python Interpreter
One of the most useful tools for writing Python code is the Python interpreter, an interactive editing and
execution environment in which commands are run as soon as you enter them and press Enter. On Unix
and Macintosh machines, the Python interpreter can usually be found in the
/usr/local/bin/python
directory, which can be accessed by simply typing the command python .
On Windows machines, the Python interpreter is installed to the
c:\python25 directory (for a Python
2.5x installation). To add this directory to your path, type the following at a Windows command prompt:
set path=%path%;C:\python25.
On a Windows system, such as with Unix/Linux, you simply type python to bring up the interpreter
(either from the
c:\python25 directory or from any directory if the Python directory has been added to
the path).
When you enter the interpreter, you ll see a screen with information like the following:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
> > >
Your Editing /Execution Environment
Because the minimum requirements for writing and running Python programs are simply an editor that
can save text files and a command prompt where you can run the Python interpreter, you could simply
use Notepad on Windows, Vim on Linux/Unix, or TextEdit on Mac, and a command line for running
programs.
One nice step up from that is IDLE, Python s integrated development environment (IDE), which is
named after Monty Python s Eric Idle and is included with Python. It includes the following useful
features:
A full - featured text editor
Syntax highlighting
Code intelligence
A class browser
A Python path browser
A debugger
A Python interpreter environment
c01.indd 2c01.indd 2 6/2/08 12:03:08 PM6/2/08 12:03:08 PM