Datasheet

being asked to exceed their capabilities, and they can fail gracefully by notifying their users that they’ve
stopped. In the best cases, you can create programs that explain what failed and why. Python offers
especially useful features that enable you to describe what conditions may have occurred that prevented
your program from working.
What All That Means Together
Taken together, these beginning principles mean that you’re going to be introduced to programming as a
way of telling a computer what tasks you want it to do, in an environment where you are in control. You
will be aware that sometimes accidents can happen and that these mistakes can be accommodated
through mechanisms that offer you some discretion regarding how these conditions will be handled,
including recovering from problems and continuing to work.
The First Steps
First, you should go online to the web site for the book, following the procedure in the Introduction, and
follow the instructions there for downloading PythonCard. PythonCard is a set of utilities that provides
an environment for programming in Python. PythonCard is a product that’s free to use and distribute
and is tailor-made for writing in Python. It contains an editor, called codeEditor, that you will be using
for the first part of this book. It has a lot in common with the editor that comes with Python, called idle,
but in the opinion of the authors, codeEditor works better as a teaching tool because it was written with
a focus on users who may be working on simpler projects. In addition, codeEditor is a program written
in Python.
Just as authors and editors have specialized tools for writing for magazines, books, or online publica-
tions, programmers also need specialized tools. As a starting Python programmer, the right tool for the
job is codeEditor.
Starting codeEditor
Depending on your operating system, you will start codeEditor in different ways.
Once it is installed on your system with PythonCard, on Linux or Unix-based systems, you can just type
codeEditor in a terminal or shell window and it will start.
On Windows, codeEditor should be in your Start menu under Programs ➪ PythonCard. Simply launch-
ing the program will get you started.
When you start codeEditor for the first time, it doesn’t display an open file to work with, so it gives you
the simplest possible starting point, a window with very little in it. Along the left side, you’ll see line
numbers. Programmers are often given information by their programs about where there was a problem,
Programs are written in a form called source code. Source code contains the instruc-
tions that the language follows, and when the source code is read and processed, the
instructions that you’ve put in there become the actions that the computer takes.
3
Programming Basics and Strings
04_596543 ch01.qxd 6/29/05 10:59 PM Page 3