From the back cover...
Python Phrasebook give you the code phrases you need to quickly and effectively complete your programming projects in Python. * Concise and Accessible Easy to carry and easy to use - lets you ditch all those bulky books for one portable guide * Flexible and Functional Packed with more than 100 customizable code snippets - so you can readily code functional Python in just about any situation...
This book does what it says it will do, namely, it gives you short pieces of Python code that solve commonly encountered Python programming problems. The problems solved and the solutions listed in the book are simple to grasp, and they realistically portray problems that Python coders would encounter when using the language for everyday tasks. The contents of the book provide complete coverage for each section of the book and what problem is solved in that section; by using the contents of the book, it should be easy to locate the code in the book that could help solve a specific programming problem. The book physically is small enough to carry in the back pocket of a pair of pants, so that it's portable enough to take just about anywhere.
The first chapter provides a 30,000 foot view of the Python language, which is helpful for people with prior Python experience, but who have not looked at any Python code in a while. The first chapter will help returning Python coders refresh their memory about language syntax and structure before diving into the heavier stuff in subsequent chapters.
Each section in the book starts off with a 'phrase' of Python code. The code 'phrase' is then explained in detail, along with sample output results (if any) from that code phrase. The chapters group related operations in Python; for example, there is a chapter on String objects, a chapter on File objects, a chapter on Database objects, and so on. The sections in each chapter generally start with easy concepts and work towards harder concepts to master as the chapter goes forward. For example, in the Threading chapter, the concept of 'threads' are explained at the beginning of the chapter, and subsequent sections in that chapter show what you can do with threads. The chapter ends with an example of how to create a Timer-interrupted Thread, meaning a Python program thread that executes at a specified interval as determined by the programmer.
This reviewer decided that the book itself deserves a 4 out of a possible 5 rating, the book delivers what it promises, namely explanations of source code examples that solve common problems encountered when working with Python.
People who purchase this book should immediately go and try to find the errata for the book (there is no errata for this book listed on the book's website as of January 2007). The reviewer found one huge mistake in the book during the process of writing this review. In Table 7.2 of the book, on page 146, lists different options that the
socket object takes in Python. The descriptions in that table are descriptions of file mode permissions, not descriptions of network socket types, which is the information that the table was supposed to contain. A sample chapter of the book is posted on the book's website, which coincidentally also lists Table 7.2 with the incorrect information as noted above.
The correct information about the arguments needed when creating a
socket object in Python can be obtained from the
help(socket) command when running Python interactively:
[manzana] python Python 2.4.3 (#1, Dec 23 2006, 20:23:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> help(socket) Help on module socket: NAME socket ...
The book does not mention the
help() method at any time as a way of getting more information about a Python object. The
help() method is a useful way of getting access to information about the classes, objects and methods of the currently running version of Python. Since Python object/method/class usage can sometimes drastically change between major revisions of the software, teaching people how to get the most current information out of the code itself could really help readers out.
In the section of the book labeled "Reader Services", in between the Contents and the Introduction, it mentions that readers who register the book should have access to errata from the book; the reviewer did not register the book, and does not know if book errata is only available to people who register the book. Other books on the publisher's website list book errata without requiring a registration or login to the publisher's site, so registration may not be needed order to view the book's errata.
Chapters in Brief
Chapter 1 - Understanding Python
- Invoking Python; built-in objects and data types; Python Objects, Modules, Classes and Functions; Error handling; System Tools
Chapter 2 - Manipulating Strings
- comparing/joining/splitting strings; searching and replacing in strings; trimming/aligning/formatting strings; executing code inside of strings;
Chapter 3 - Managing Data Types
- creating and working with lists, tuples and dictionaries
Chapter 4 - Managing Files
- Opening and closing files; reading files line-by-line; writing files; renaming files; walking a directory tree; searching for files based on the file's extension; creating and managing a TAR/ZIP file
Chapter 5 - Managing Threads
- Starting a new Thread; Creating and exiting threads; synchronizing threads; implementing a threaded queue; implementing a timer-interrupted thread
Chapter 6 - Managing Databases
- Working with DBM files; Pickling data for storage and retrieval; Working with Shelve files; Working with MySQL databases
Chapter 7 - Implementing Internet Communication
- Opening sockets for client-side and server-side communications; sending streaming data; using the SMTP, POP3 and FTP protocols
Chapter 8 - Processing HTML
- Parsing URLs; Opening and retrieving HTML documents
Chapter 9 - Processing XML
- Loading an XML document; checking for well-formed XML documents; Accessing child nodes and attributes; Working with XML DOM trees; Searching XML documents; Extracting text from XML documents; Parsing XML tags
Chapter 10 - Programming Web Services
- Using Python for CGI scripts; Creating HTTP servers for GET/POST/CGI requests; Sending HTTP GET/POST requests from client scripts; Creating XML-RPC clients and servers; using SOAPpy to access SOAP services