Book Examples Distribution

This section briefly discusses the book’s example source code distribution, and covers example usage details.

The Book Examples Package

The Examples\PP2E CD directory is a Python module package that contains source code files for all examples presented in this book (and more). The PP2E package in turn contains nested module packages that partition the example files into subdirectories by topic. You can either run files straight off the CD, or copy the PP2E directory onto your machine’s hard drive (copying over allows you to change the files, and lets Python store their compiled bytecode for faster startups).

Either way, the directory that contains the PP2E root must generally be listed on the Python module search path (normally, the PYTHONPATH environment variable). This is the only entry that you must add to the Python path, though; import statements in book examples are always package import paths relative to the PP2E root directory unless the imported module lives in the same directory as the importer.

Also in the examples package, you’ll find scripts for converting example files’ line-feeds to and from Unix format (they are in DOS format on the CD--see http://examples.oreilly.com/python2), making files writable (useful after a drag-and-drop on Windows), and more. See the README files at the top of the Examples and PP2E directory trees for more details on package tree usage and utilities.

Running the Demo Launcher Scripts

The top level of the ...

Get Programming Python, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.