David M. Beazley is a long-time Python enthusiast, having been involved with the Python community since 1996. He is probably best known for his work on SWIG, a popular software package for integrating C/C++ programs with other programming languages, including Python, Perl, Ruby, Tcl, and Java. He has also written a number of other programming tools, including PLY, a Python implementation of lex and yacc. Dave spent seven years working in the Theoretical Physics Division at Los Alamos National Laboratory, where he helped pioneer the use of Python with massively parallel supercomputers. After that, Dave went off to work as an evil professor, where he briefly enjoyed tormenting college students with a variety of insane programming projects. However, he has since seen the error of his ways and is now working as a professional musician and occasional software consultant in Chicago. He can be contacted at http://www.dabeaz.com.
Acknowledgments
This book would not be possible without the support of many people. First, Id like to thank Timothy Boronczyk for his feedback regarding the third edition. Id also like to acknowledge past technical reviewers Paul DuBois, Mats Wichmann, David Ascher, and Tim Bell for their valuable comments and advice that made earlier editions a success. Guido van Rossum, Jeremy Hylton, Fred Drake, Roger Masse, and Barry Warsaw also provided tremendous assistance with the first edition while hosting me for a few weeks back in the hot summer of 1999. Last, but not least, this book would not be possible without all of the feedback I received from readers. There are far too many people to list individually, but I have done my best to incorporate your suggestions for making the book even better. Id also like to thank all the folks at Sams Publishing and Pearson Education for their continued commitment to the project and assistance. Jenny Watson, Scott Meyers, Andy Beaster, and Bart Reed all helped out to get this edition out the door in good shape. A special thanks is in order for Robin Drake, whose tremendous effort in editing previous editions made the third edition possible. Finally, Id like to offer a special acknowledgment to my musical partners in crime: Jim Trompeter, David Bloom, Thomas Mucha, Trent Harris, Matt Mayes, Marc Piane, and Alex Alvarado. They had absolutely nothing whatsoever to do with Python or this book, but they put up with me when I was spending far too much time working on the book and not enough time working on interesting new bebop lines. Thanks guys.
We Want to Hear from You!
As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what were doing right, what we could do better, what areas youd like to see us publish in, and any other words of wisdom youre willing to pass our way.
You can email or write me directly to let me know what you did or didnt like about this bookas well as what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to include this books title and author as well as your name and phone or email address. I will carefully review your comments and share them with the author and editors who worked on the book.
E-mail: |
Mail: | Mark Taber Associate Publisher Sams Publishing 800 East 96th Street Indianapolis, IN 46240 USA |
Reader Services
Visit our website and register this book at www.samspublishing.com/register for convenient access to any updates, downloads, or errata that might be available for this book.
Introduction
T HIS BOOK IS INTENDED TO BE A CONCISE REFERENCE to the Python programming language. Although an experienced programmer will probably be able to learn Python from this book, its not intended to be an extended tutorial or a treatise on how to program. Rather, the goal is to present the core Python language, the contents of the Python library, and the Python extension API in a manner thats accurate and concise. This book assumes that the reader has prior programming experience with Python or another language such as C or Java. In a addition, a general familiarity with systems programming topics (for example, basic operating system concepts and network programming) may be useful in understanding certain parts of the library reference.
Python is freely available for download at http://www.python.org. Versions are available for almost every operating system, including UNIX, Windows, Macintosh, and Java. In addition, the Python website includes links to documentation, how-to guides, and a wide assortment of third-party software.
The contents of this book are based on Python 2.4. However, readers should be aware that Python is a constantly evolving language. Most of the topics described herein are likely to be applicable to future versions of Python 2.x. In addition, much of the material is applicable to earlier releases. To a lesser extent, the topics in this book also apply to alternative Python implementations such as Jython (an implementation of Python in Java) and IronPython (an implementation of Python for .NET). However, those implementations are not the primary focus.
Just as Python is an evolving language, the third edition of Python Essential Reference has evolved to make use of new language features and new library modules. In fact, since the publication of the second edition, Python has undergone a dramatic transformation involving significant changes to core parts of the language. In addition, a wide variety of new and interesting features have been added. Rather than discussing these changes as a mere afterthought, the entire text has been updated to reflect the modern state of Python programming. Although no distinction is given to new features, detailed descriptions of language changes can be found at http://www.python.org.