Python Phrasebook Review by Meher Koli
Author: Brad Dayley The Python Phrasebook is a handy tool (small book) for beginners which aids in getting a quick reference or syntax needed for the Python language. The book is around 250 pages divided across ten chapters covering most of the essential commands and code snippets which can be very handy for getting most of the basic functionality expected by a novice programmer.
Since this is a phrasebook do not expect any detailed or elaborate explanations on the topics covered in the book. Also to maintain the size of the book it doesn't cover the entire breadth of python but the ones that are really vital and very indispensable. The first chapter is an introduction to Python helping you to get started with invoking the python shell and understanding some of the built-in types, objects, modules and classes.
The next couple of chapters deal with string manipulation and data types. Some of the methods for string objects mainly for comparing, joining, splitting and replacing are explained with the precise examples for each method. The only missing here was the number formatting and dealing with dates. The well known data types list, tuples and dictionaries are discussed with snippets to store, manipulate and get data from them.
The fourth chapter is all about file management (opening, closing and writing), in addition to the regular built-in file functions in python there are other examples which show you the ways to utilize the os module for various other things like creating a tar file or a zip file and doing a search in the directory tree. The next one is small chapter on managing threads which talks about the very basics of starting a thread, stopping it and synchronizing multiple threads. The chapter about database management really covers a bunch of modules needed for getting most of the things with databases. Code snippets using MySQLdb and anydbm modules to connect to the database are presented in addition few examples on pickle and cPickle modules.
The last three chapters help the user with getting some of the common tasks associated with the web technologies mainly processing the html, xml and cgi scripts.
The code snippets provided in these sections give you a fair chance to understand and used httplib, urllib2, urlparse, xmlparser and cgi modules without going to through the details of the entire modules. Also the last chapter has some examples of the python classes and functions to connect to a web server and send a GET Request / POST Request and handle the response.
Most of the code snippets in the book are about few lines and even the biggest ones are not more than 100 lines. In short this is a well written book offering the most essential commands and syntaxes in python in a short and sweet manner.