I l@ve RuBoard |
B.2 Book Examples DistributionThis section briefly discusses the book's example source code distribution, and covers example usage details. B.2.1 The Book Examples PackageThe 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. B.2.2 Running the Demo Launcher ScriptsThe top level of the CD's Examples\PP2E package (see http://examples.oreilly.com/python2) includes Python self-configuring scripts that can be run to launch major book examples, even if you do not configure your environment. That is, they should work even of you don't set your PATH or PYTHONPATH shell variables. These two scripts, PyDemos and PyGadgets, are presented in Chapter 8, and described more fully in both this book's Preface and the CD's README files (see http://examples.oreilly.com/python2). In most cases, you should be able to run these scripts right off the book's CD by double-clicking on them in a file explorer GUI (assuming Python has been installed, of course). |
I l@ve RuBoard |