CHAPTER 1 ■ INTRODUCING PYTHON
5
Choosing to Code with a Text Editor
My preferred method of creating Python scripts is to use a plain text editor, with a few basic
programming features. Programs like notepad (especially notepad2/++), BBedit, gedit, NEdit and Kate
are ideal for this task. A variety of editors are available that offer specific enhancements for
programmers, such as syntax highlighting, which is useful for showing coding errors immediately as you
type. Old-school hackers may prefer to use Vi or Emacs. Python does not dictate what software you use
to create the code; the choice is up to you. Do not attempt to use word-processing software, such as
Word or OpenOffice for this task; it will mess you up badly. Be warned!
Choosing to Code with an Integrated Development
Environment
An integrated development environment (IDE) is a graphical interface with lots of useful features
designed to make programming with Python even easier. You still have to type the code in the same way,
but you can do all your coding using a single application, and these programming environments can
provide some useful shortcuts and reminders. There are now several Python-specific IDEs. Popular
applications include IDLE (which is bundled with Python itself), Eric (you may notice a theme here,
nudge nudge, wink wink, say no more...), Geany, DrPython, and SPE. Python is also supported by more
general programming environments like Bluefish and a whole host of others. This book doesn’t cover
the use of IDEs or any of the alternative distributions of Python, because each of these approaches
would require a chapter unto themselves, at the very least. However, the examples contained in this
book will still work if you do choose to explore these options. This book will take the simplest approach,
using tools that come as standard with most operating systems; that is, a text editor and the Python
Interactive Shell.
Getting Started with Programming
The process of writing a new program usually starts with a problem. Before you can code anything, you
need to have an idea of what you want to create, the problem you wish to solve, and a fairly good idea of
how to solve it. Chapter 2 will take you through the process of designing software, known as the software
development cycle. Usually, this is something that you have to learn separately, as most programming
manuals go straight into the details of the language, assuming you will have studied program design at
college or in the process of learning some other programming language. This can lead you to create code
that is difficult to read and understand and makes fixing problems later a nightmare. Understanding the
principles of software design can dramatically speed up the process of creating new software and help
ensure that important details are not missed out.
In Chapter 3, you start coding those designs in Python. You will learn about constructing the basic
units of data, words and numbers, and how to combine and manipulate them. In Chapter 4, I will show
you how to compare values, make choices, and deal with errors. The subsequent chapters go through
the process of refining those designs, breaking them down into manageable chunks, and expanding your
understanding of the Python programming language so you can turn your ideas into fully fledged,
functional computer programs.