Editors: Alex Martelli, Anna Martelli Ravenscroft & David Ascher
Pub Date: 2005
Cover Price: $49.95
- What the Book is About
- Python (www.python.org)
is a powerful scripting language that is object-oriented, type-safe, and extensible.
It has more capability than Perl, but it has a readable syntax similar to C or C++.
Yet, in learning any new language, even the experienced programmer finds himself
asking, "How do I ...?" As the title of the book suggests, this is a "cookbook"
filled with "recipes" that answer many of the "How do I?" questions
one might ask (over 300 recipes in this second edition).
- Target Audience
- This book is written for Python
programmers (Python 2.3 is installed as part of Mac OS 10.3 and later - from a terminal
window, enter "python"). It is not a tutorial for basic language syntax,
but it does cover topics ranging from basic string manipulation to extracting attachments
from e-mail. Some of the recipes fall into the "Gee, why didn't I think of that?"
category, while others are very sophisticated. Any Python programmer can expect to
learn something from this book.
- What To Expect
- Like a food cookbook, this is
not the kind of book you read from cover to cover. There are 20 different chapters
covering a wide range of topics. Within each chapter are (on average) about 20 recipes.
Some of these are Windows-specific; some are Unix-specific (which does include OS
X), and some are Mac-specific.
Each recipe includes an overview of the problem being solved, the code to solve the
problem, and then a discussion of the reason why the code presented is a good (or
optimal) solution. It is this discussion that is most valuable. Understanding the
"why" behind a solution is essential to being able to reproduce that solution.
The chapters I expect to get the most use out of include "Debugging and Testing",
"Processes, Threads, and Synchronization", "Network Programming",
"Distributed Programming", and "Extending and Embedding". I also
enjoyed playing with some of the recipes in "User Interfaces".
- The book is full of complete code
samples. Each and every recipe (except the Windows-specific ones, of course) can
be demonstrated on your Mac just by typing in the code to the Python interpreter.
For me, the best way of learning is by doing, and working code is a great help.
Wasn't it Steve Jobs who said, "Theft is the most sincere form of flattery."
Or was that just TV artistic license. In any event, the code in this book can be
shamelessly stolen and integrated into your projects.
- Mac Guild Grade
- B+ (Great)
- Final Words
- Python Cookbook is precisely what
it would seem to be. It is a reference book filled with recipes for doing useful
or interesting or even esoteric things in Python. It won't teach you the language,
but it will help you extend your grasp of what can be done using the language. If
some chapters seem irrelevant today, just wait a while. Chances are good that you
will be asked to do something outside your "box" tomorrow.