Python Cookbook, 3rd Edition – Breaking Away from Python 2 to Python 3 – #programming #bookreview

Python Cookbook, 3rd Edition
David Beazley & Brian K. Jones
(O’Reilly - paperback, Kindle)

PYTHON 3 users will be very pleased with this new book. Those who still cling to Python 2 likely will not.

Even though “most working Python programmers continue to use Python 2 in production,” its authors concede, and “Python 3 is not backward compatible with past versions,” this third edition of the popular Python Cookbook is intended to be used only with Python 3.3 and above.

“Just as Python 3 is about the future, this edition…represents a major change over past editions,” Beazley and Jones state. “First and foremost, this is meant to be a very forward looking book. All of the recipes have been written and tested with Python 3.3 without regard to past Python versions or the ‘old way’ of doing things. In fact, many of the recipes will only work with Python 3.3 and above.”

THEIR “ultimate goal,” they point out, was “to write a book of recipes based on the most modern tools and idioms possible. It is hoped that the recipes can serve as a guide for people writing new code in Python 3 or those who hope to modernize existing code.”

The 687-page Python Cookbook, 3rd Edition is not intended for beginning programmers. However, beginners can learn a few things from it and keep the book on their shelves for future use as they gain experience with Python 3.

And, it can be a helpful guide if you are working to update some Python 2 code to Python 3. According to the authors, “many of the recipes aim to illustrate features that are new to Python 3 and more likely to be unknown to even experienced programmers using older versions.”

THE book offers 15 chapters of how-to recipes organized into the following major categories:

  1. Data Structures and Algorithms
  2. Strings and Text
  3. Numbers, Dates, and Times
  4. Iterators and Generators
  5. Files and I/O
  6. Data Encoding and Processing
  7. Functions
  8. Classes and Objects
  9. Metaprogramming
  10. Modules and Packages
  11. Network and Web Programming
  12. Concurrency
  13. Utility Scripting and Administration
  14. Testing, Debugging, and Exceptions
  15. C Extensions

Each of the approximately 260 recipes is presented using a “problem-solution-discussion” format. Here are a few recipe titles chosen at random:

  • “Combining and Concatenating Strings”
  • “Reformatting Text to a Fixed Number of Columns”
  • “Bypassing Filename Encoding”
  • “Iterating over the Index-Value Pairs of a Sequence”
  • “Capturing Variables in Anonymous Functions”
  • “Implementing Stateful Objects or State Machines”
  • “Enforcing an Argument Signature on *args and **kwargs”
  • “Creating Custom Exceptions”
  • “Writing a Simple C Extension Module”

SOME of the book’s code examples are complete. But others, the authors caution, “are often just skeletons that provide essential information for getting started, but which require the reader to do more research to fill in the details.”

If you are serious about Python and keeping pace with its progress, you should seriously consider getting this excellent how-to book.

Si Dunn

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s