This appendix provides notes on how to install Python and the Twisted framework. In most cases, it is quite easy to do so — even if you have little prior experience. For additional information, see the Python and Twisted home pages.
Most Linux distributions include Python. To find out, try the command
python at the shell prompt. If Python is
installed, the interpreter will show its version, and start in interactive mode
(hold down Ctrl and press D to exit).
If your Python is very old (e.g., version 1.5.2), you probably want to upgrade it. For example, the latest stable version of Twisted is not available for Python variants earlier than 2.2.X. When upgrading Python, do not delete your old version. Different Python variants usually coexist well, and your system might be relying on the older version for some of its functions.
Before upgrading Python, check that you do not already have a later version
installed alongside the earlier one (i.e., as additional commands like
python2.2). If so, you can use the additional
command to explicitly invoke the more recent interpreter.
At the time of this writing, the most recent stable Python release is 2.3.2.
Red Hat Linux users can download the RPMs. Do not
forget the Tkinter RPMs if you wish to run the GUI
example. Tkinter also requires Tk. The version on the Red Hat install disks
should work fine, or search for
tk at the bottom
of the Red Hat download
To install the RPMs, copy them to a separate subdirectory, use the
su command at the shell prompt to become the
superuser (you will be asked the root password for the system), then
rpm -i subdirname/*.rpm.
Debian GNU/Linux 3.0 ("woody") users can
get a slightly older, 2.2.X series Python in just two steps. Become the
su at the shell prompt, then enter the
root password) and issue the command
python2.2-tk. In addition, you will need
apt-get install python2.2-dev) if you want to install Twisted later.
On Linux, Python can also be built from source, usually without too much work. See Python on Other Platforms for details.
Python is very easy to set up for Windows users. From the Python download page, click and run the executable installer. The link is to version 2.3.2 of Python, the latest at the time of this writing. Everything you need to use Tkinter is also included in the installation.
Python for Windows provides two variants of the interpreter:
pythonw. The latter can be used to execute
programs that do not require a console — such as the GUI
example given earlier.
For Python on the Macintosh, see the MacPython download page.
In general, on Unix and compatible systems (such as Linux), Python can be built using the source code. Here is a brief synopsis of the procedure, quoted from the Python version 2.3.2 download page.
All others should download either Python-2.3.2.tgz or Python-2.3.2.tar.bz2, the source archive. The
tar.bz2is considerably smaller, so get that one if your system has the appropriate tools to deal with it. Unpack it with
tar -zxvf Python-2.3.2.tgz(or
bzcat Python-2.3.2.tar.bz2 | tar -xf -). Change to the Python-2.3.2 directory and run the
make installcommands to compile and install Python.
If you're having trouble building on your system, check the top-level README file for platform-specific tips, or check the Build Bugs section on the Bugs web page.
Note that the last command (
needs to be run as the superuser.
At the time of this writing, the latest stable version of Twisted is 1.1.0.
From the download
page get the
tar.bz2 archive (see Python on
Other Platforms for a discussion of the difference between the two
formats). You may need to scroll down on the page until you find the
production version (downloads for the latest alpha release are sometimes listed
first). Choose the archive with documentation included, unless disk space
is really limited or your Internet connection is excessively slow.
After uncompressing the archive, change to that directory (using a shell),
become superuser (root), and issue the command
install. This will make Twisted available system-wide.
The Twisted download page includes Windows installers. If the alpha version is listed first, scroll down on the page until you get to the stable release (1.1.0 as of this writing). Choose the installer with documentation, unless you are low on disk space or have a slow Internet connection. Make sure that you use the installer that matches the Python version that you installed earlier. Run the installer, and follow the prompts as usual when adding a new application under Windows.
This appendix provides additional notes on the resources referred to in the article. First, some of the classic papers ("The Design Philosophy of the DARPA Internet Protocols" and "End-to-End Arguments in System Design") on the design of the Internet are enlightening and fascinating to read. An understanding of the underlying architecture will help you in developing your own programs.
Regarding the use of regular expressions to analyze text, there are many
online resources. Even the discussions that are not specific to Python can be a
very useful guide. Two Python-centric resources on regular expressions are the
HOWTO" and the documentation of the
module itself. For an overview of recent developments in regular
expressions — as well as how Python's implementation fits into the
overall taxonomy — see "What's New with Regular Expressions." The article is written by the author of Mastering Regular Expressions, a book for those who really want to become experts in this area.
Python programming is also well covered in numerous books, articles and online resources. The Python web site, for example, has an excellent documentation section. In particular, the tutorial is a quick but gentle introduction to the language. Python comes with a large, diverse library; the documentation is accessible via the library reference and module index pages. "An Introduction to Tkinter" provides a very helpful tutorial on this Python GUI library.
Papers from PyCon DC 2003 are available online, several on Twisted. The Twisted framework's web site also provides extensive documentation. In particular, the "howto" and example pages offer plenty of easy-to-follow information on the many diverse facilities of this system.
C. Example Files
George Belotsky is a software architect who has done extensive work on high-performance internet servers, as well as hard real-time and embedded systems.
Return to Python DevCenter.
2003-12-31 05:26:40 anonymous2 [View]
Nice Little Tutorial
2003-11-11 11:08:52 anonymous2 [View]
***Warning*** Errors in Download Files
2003-11-07 09:32:16 belotsky [View]
***Warning*** Errors in Download Files - Now Fixed
2003-11-07 14:59:29 sarahkim [View]