
P1: JYS
app01 JWBK378-Fletcher May 1, 2009 19:56 Printer: Yet to come
Appendix A
Python
In this appendix, we provide a whirlwind tour of the Python programming language. It will in
no way be exhaustive and is not intended to negate the need for learning the language more
comprehensively using the many excellent resources available teaching Python.
1
Nonetheless,
it should be enough to enable a newcomer to the language to get started.
A.1 PYTHON INTERPRETER MODES
The Python interpreter can be executed in one of two modes: ‘interactive’ or ‘batch’. When
run interactively in a shell or on Windows, at a command prompt, the interpreter will wait for
input from the user, and when sufficient input has been made for a statement to be executed
will execute that statement immediately and go back to waiting for the next. In batch mode, a
complete Python script stored in a file is given to the interpreter and executed, all at the same
time.
A.1.1 Interactive Mode
To launch an interactive session with the interpreter, from your shell or command prompt, issue
the command python -i. All being well, the interpreter should then indicate its willingness
to begin processing statements by displaying its primary prompt, which looks like a sideways
chevron ‘>>>’. On Windows, starting a session might look something like this:
c:\Documents and Settings\PythonUser>python -i
python -i
ActivePython 2.5.1.1 (ActiveState Software ...