Python Cookbook (3e) |
Author: David Beazley & Brian K. Jones A Python cookbook is surely handy, given the complexity of the language - but only if it covers a good range of topics. The short version of this review is - if you write Python just get a copy. It will not only save you time in the long run you should get a lot of fun out of reading it. Cookbooks are difficult to review because which recipes the reader is going to find useful depends on the reader. The best you can do is make a guess on how generally useful the topics covered are and how "non-obvious" they are. In this case, while there are a few simple recipes the majority take even the experienced Python programming into deep water. The only big problem you might have with this book is that it covers Python 3 rather than 2 and this means some of the recipes might well not work as listed under the still-popular Python 2. This said, even if you are still using Python 2 it is worth finding out how to convert these examples where necessary - for one thing doing so might get you to switch to Python 3. This is a big book with 600 pages and 15 chapters so a review can only give you a rough idea of what it contains. The first chapter tries to start off gently with some simple examples of working with sequences but it quickly digs deeper into sorting, Dictionaries, priority queues and so on. Chapter 2 is on strings and text and surely this has to contain some boring and obvious recipies - but no. Regular expressions and Unicode make things more complicated and by the end of the chapter we have a recipe for writing a recursive descent parser - a simple one, of course! After text we move on to numbers, dates and times and this finishes the books look at "simple" data Next we have a chapter on iterators and generators one of Pythons most powerful but misunderstood features. The examples given should make sure you understand and make sure why you need to understand.
Chapter 5 moves us back to more traditional territory with a look at files and I/O. If anything this is probably going to be the chapter that you know most about, but even here there are some interesting topics - iterating over fixed size records, serializing Python objects and so on. Chatper 6 goes deeper into the same sort of topic with a look at encoding and processing - JSON, CSV, XML, relational database, Base64 and so on. Chapter 7 brings us back to central language features with an in-depth exploration of how to do things with functions - metadata, any number of parameters, default arguments, inline callbacks and closures. Next we have the same sort of examination of objects and classes. You really do need to understand object oriented programming to make use of these recipes and they go as far as making use of some standard patterns. Chapter 9 dives into metaprogramming - the part of Python that is often classified as "difficult". We find out about wrappers, decorators, metaclass and how to parse Python source code. Chapter 10 is a short account of using packages and modules. Chapter 11 is about Networking and Web programming and covers HTTP, TCP, UDP, REST, SSL, sockets and more. Chapter 12 is about concurrency and it gives examples of working with threads and the limitations of the GIL and how they might not be limitations at all. After chapter 12 things wind down with a look at using Python as a scripting/admin language, a chapter on debugging/testing and a final one on creating C extensions. As always you might be unlucky and not discover one recipe that is relevant to what you are trying to do, but as already said you will learn a lot about Python on the way. This is not a book for the beginner as it assumes that you can program in Python to a reasonable level of skill. While most of the descriptions are good, you will from time-to-time need to lookup language features that you might not be so familiar with. Sometimes the recipe format is a bit irritating in that a problem is stated and solved but you have to wait to the discussion to find out how it all works. I think that this is one recipe book that probably has an "advanced Python" tutorial book hidden inside. Despite the minor niggles - just buy the book. Highly recommended to the intermediate to advanced Python programmer.
|
|||
Last Updated ( Wednesday, 31 July 2013 ) |