Python Cookbook, 2nd Edition
review by Tony Cappellini, October 2005
![]() | ||
| ||
| After my initial first pass through the table of contents, it appeared that the chapter ordering had remained mostly the same as the first edition. Further reading proved this to be wrong. Fortunately the authors included an insightful and concise comparison of the two editions, which was very useful in comparing and contrasting these two books. "If you already own the first edition, you may be wondering whether you need this second edition, too. We think the answer is "yes". The first edition has 245 recipes; we kept 146 of those (with lots of editing in almost all cases), and added 192 new ones, for a total of 339 recipes in this second edition. So, over half of the recipes in this edition are completely new, and all of the recipes are updated to apply to today's Python releases 2.3 and 2.4". I personally agree with this. If you already have the first edition, I would not sacrifice it for the second edition, but would keep it to complement the sescond edition, especially if you have to run older versions of Python. If you are new to Python, then buying the second edition alone would probably suffice, since it focuses on the features of Python 2.3 and 2.4. | ||
| Following the tradition of the first edition, the preface contains a concise summary of the category of recipes each chapter contains, as well as the names of the persons who wrote the chapter introductions. Not surprisingly, the names of the person(s) who contributed recipes to each chapter are provided as well | ||
| I particularly like Chapter 4: Python Shortcuts because these recipes can be ready and digested quickly without having to resort to other Python documents. The Problem, Solution, Discussion approach helps me understand new concepts quickly, especially when several solutions are shown, and their successive improvements are elaborated on. I also find the "See Also" references extremely helpful for further examples or reinforcement on a given topic. | ||
| A feature which is unique to the second edition are the "gotcha" paragraphs, strategically located throughout the book. These paragraphs are emblazoned with an icon of a spring-loaded bear trap. The "gotcha" sections are provided to illustrate some pitfall which is easily stumbled upon, as well references to some of Pythons roots, and other interesting tidbits. This edition of the Python Cookbook features a chapter on Iterators and Generators, which is enlightening for those of us who haven't used them yet. The last (but possibly the most-anticipated) chapter is dedicated to the dark side of Python, the controversial Descriptors, Decorators, and Metaclasses. Since this is an advanced area, I can't write anything about this chapter other than "read it for yourself"! | ||
| hould you buy this book? If you are new to
Python, this book provides a wealth of solutions as well as many new
ideas. When I'm not looking for any specific solution, I will browse
the table of contents for something interesting, but then find myself
going from recipe to recipe and spending more time than expected. A convenient link for downloading code examples from the cookbook can be found on Oreilly's website here. | ||
| Only one minor regret comes to mind. I wish the book would have cross referenced OS-specific recipes for those of us who need to look for solutions specific to Windows, Linux, or the Mac. I had suggested this to the authors before the book was published, but my suggestion was too late for them to implement into the book and maintain the publishing schedule. Hopefully, the Python Cookbook website can still implement this idea at some point in its evolution | ||
