Amazon.com: Customer Reviews: Python Cookbook
Safety Month BOTMKT Amazon Fashion Learn more Discover it $5 Albums The best from Bose just got wireless Fire TV Stick Sun Care Patriotic Picks STEM Amazon Cash Back Offer AnnedroidsS3 AnnedroidsS3 AnnedroidsS3  Amazon Echo  Echo Dot  Amazon Tap  Echo Dot  Amazon Tap  Amazon Echo Starting at $49.99 All-New Kindle Oasis Segway miniPro

Your rating(Clear)Rate this item


There was a problem filtering reviews right now. Please try again later.

on September 6, 2005
Good:
As other reviewers have pointed out, this book offers solutions for a broad range of programming problems. There is something for every level from beginner to expert (the most advanced examples were well over my head). The recipes are enhanced by discussions that are mostly very well and clearly written, giving insight into the design and logic of the presented recipes. They thus guide the way to adapting the recipes to your own programs.
So, most of the content of this book is good. 4-5 stars for that.
Bad / Production:
The recipes (so I gather) are mostly edited versions of what is available at ActiveState's online cookbook. However, the edited versions seem not to be available online (at least there is no pointer, and O'Reilly's website does not provide one either). Nor does the book include a CD. For all the hype in the book about this being a book by the Python community for the Python community, this is disappointing. Not even pointers are provided to on-line cookbook recipes that were used as starting points for those printed in this book. This is just bad craftsmanship on the part of O'Reilly. (On a similar note, the back cover promises a foreword by Guido but there isn't one.)
Bad / Content:
Sugar is sweet but bad for your health. So it is with this book - too many recipes add only (syntactic) sugar but no minerals and vitamins. Several 'shortcuts' are just wasted ink and breath - they will save you 1-2 lines of code when writing a function but then you have to import the shortcut implementation and get to make the extra function calls... Where these 'shortcuts' help to avoid some Python gotchas, it would have been more useful to just document the gotcha in question and show how to avoid it in straight Python code without any sugaring. Case in point: The once-only initialization of function default arguments. If you write:
def foo(bar=[])
bar.append(quux)
then previous quuxes will be lurking in the bars of every subsequent foo call that does not pass bar itself. So, you must write:
def foo(bar=None):
if not bar: bar=[]
to get an empty [] for every call. Now does this 'problem' merit a more elaborate, sugary 'solution'? I don't think so.
Some recipes are recipes for disaster. We are told how to automatically call the __init__ routines of every superclass... what we are not told is how to automatically call them in the appropriate order or with the respective arguments for making things work. How often do you write an __init__ that takes only the 'self' argument? Sure, it occurs, but... The omission of implicit superclass calls was a conscious design choice in Python and a wise one at that. Too many recipes like this one just want to show you how to subvert Python's conscious design choices. The sweet taste won't last but give way to heartburn.
For a book of this scope and design it is of course impossible to avoid criticism of the kind 'why did you include A but not B...'
Still, here goes:
XML: There are excellent libraries such as ElementTree and now cElementTree that offer fast, clean and 'Pythonic' alternatives to the standard library modules for XML parsing. More than just a URL pointer should have been provided.
Web programming: Only Jython and Twisted are mentioned as alternatives to CGI. Now Twisted may be the greatest thing since sliced bread, but ordinary mortals will never know, because it has about the the most confusing and unfathomable documentation of anything on the web (ooh I forgot Zope...). Presenting Twisted 'recipes' (or rather, plugs) with 'discussions' that drone about its power but are again just the same handwaving stuff as in the on-line docs is useless.
(If you just want to get your web stuff done with minimal pain: For simple PHP-like embedded scripting but with the advantages of Python, look at Spyce, and for an easy application server, look at Cherrypy or Webware).
So, altogether, a good book but not quite on par with e.g. Python in a Nutshell.
22 comments|109 people found this helpful. Was this review helpful to you?YesNoReport abuse
on August 6, 2006
String handling, money, time, dates. Email, network sockets, cgi, xml. The staples of the cookbook, and Python Cookbook certainly has these. However, interspersed throughout are chapters that seem to have come from at least one other completely different book, a more discursive rumination on Python programming in general. Each chapter begins with a mini essay from a Python luminary, and the discussion of each recipe is fairly extensive.

If you do any scientific or engineering work, you'll know that Python is everywhere on the scientific desktop, providing bindings, scripting and GUI front ends for ancient Fortran/C monstrosities. Reflecting this interest, there is a strong emphasis on performance, with chapters devoted to algorithms and searching and sorting.

Elsewhere, those who have graduated from the plethora of beginner's books, but have been bemused by the complete lack of any intermediate texts, will be pleased to find chapters on Python shortcuts (getting the most out of sequences for the most part) and one on generators and iterators. Futher, there is a chapter on OOP the Python way (including examples of dynamic delegation and design patterns implementation), and one on metaclasses.

This is an extremely useful book, particularly the chapters on using Python's basic collections, which will furnish the reader with some essential idioms for efficient use. However, this, and the OOP chapters would have been better as a separate book. But in lieu of a Thinking in Python or Effective Python, you need this book if you want to do any serious development in Python.

As a cookbook, it has everything you will be expecting as a springboard for exploring the standard library, except for regular expressions. But these are so well covered in introductory books, that you won't need enormous coverage here. On the other hand, the material is presented in a fairly wordy manner, which makes for interesting reading, but for dipping in and out, makes finding things more difficult than it might be.

The other notable thing about Python Cookbook is that it has rather a large number of errors in it. You will want to check the O'Reilly website for the errata, especially if you don't have the most recent printing, rather than scratching your head over why the Singleton implementation doesn't work at all.

Nonetheless, this is a vital resource for Python 2.4 users; even if you don't think you need a traditional cookbook, there is an enormous amount of material here you can benefit from.
0Comment|11 people found this helpful. Was this review helpful to you?YesNoReport abuse
on November 1, 2005
Full disclosure: I purchased the first edition of this book, and received the second edition as a reviewers copy. I work for Zope Corporation.

The O'Reilly Python Cookbook is a fun resource for Python programmers at most levels. The fun comes in part from the personalities that shine through the introductions and the community-authored recipes gathered from the ActiveState Python Cookbook website. The other fun comes from the smorgasbord of topics and technologies laid out for the reader, encouraging browsing and experimentation. New Python programmers will find recipes that highlight some of the newer features of the Python language, and experienced Python programmers will likely find thought-provoking recipes both peripherally and directly related to their specialties and interests.

Like the first edition, this second edition covers a wide range of topics. Each topic has a usually-interesting introduction by well-known names in the Python community. Some topics are of general interest-shortcuts and algorithms, for instance-while others explore somewhat more specialized topics, such as networks, XML, and databases. Each cookbook recipe I read was impressively short, while often still having enough weight to them to address non-toy usages of the approaches. Many examples can also be used as introductions to the modules and packages they use. Another important similarity to the first edition is that a portion of the proceeds from the book sales are donated to the Python Software Foundation.

This edition of the cookbook does have some significant changes from the previous one. While the first edition addressed Python versions in the 1.x and 2.x line, this one addresses only Python 2.3 and 2.4. It adds about a third more recipes than the first edition, and tops the first edition's page count by over 200 pages. Some of the new additions address relatively new packages, such as the datetime, dateutils, pytz, and decimal packages, while others focus on older packages that are waxing in their influence and popularity, such as Twisted. Many recipes are more polished, such as the "Synchronizing All Methods in an Object," which has an arguably more general purpose approach and an interesting discussion in the new edition.

Omissions are sometimes as interesting as inclusions in recipe books, but an interpretation of their significance can be difficult. The new edition dropped almost 100 of the first edition's recipes. In the "Distributed Programming" topic, the SOAP references in the first edition have disappeared, and a recipe for Twisted's Perspective Broker has surfaced. While the Perspective Broker is an interesting technology with an elegant cookbook example, the seeming judgement-SOAP is now less worth discussion than one of the Twisted project's packages-might raise some eyebrows. Similarly, Zope and the ZODB (Zope Object Database) are acknowledged as heavyweights in the introductions to their respective topics ("Web Programming" and "Persistence and Databases"). Zope 3 is even granted a rave review: "The new, revolutionary major release, Zope 3, makes Zope more Pythonic and powerful than ever." But not a single recipe can be found for either, in either edition. Perhaps that simply is indicative that the Zope community ought to pay more attention to the Cookbook website.

This returns us to the initial observation of this review: the cookbook is a community driven project, and thus reflects the personalities of the programmers who contributed to it, rather than necessarily to trends of the Python or IT community. But it also benefits from the energy and enthusiasm of the contributors who often have palpable excitement for the technologies they are demonstrating. This also makes me more interested in the book as a source for introductions than as a source for ready-made recipes.

If a picture is worth a thousand words, a working, explained example of a new package ought to be worth quite a few too. The cookbook is a fun browse and a fun introduction to other aspects of the Python language. While I have found myself using one or two of the recipes from the first edition, that use alone is not enough to justify the cover price. It is more compelling to me as a fun introduction to Python topics and approaches. In that light, I recommend it.
0Comment|22 people found this helpful. Was this review helpful to you?YesNoReport abuse
on February 18, 2009
I bought this book when Python was relatively young and it definitely got the job done on more than a few occasions. The language (and the book) has evolved and some of the recipes are a bit outdated. If you look up Python Cookbook recipes on Google or some other search engine, it will take you to the ActiveState site that has all of these recipes and more. Two stars because the book is valuable in that it is concise - searching through a slew of recipes on a site can be a bit of a chore.
0Comment|12 people found this helpful. Was this review helpful to you?YesNoReport abuse
on April 24, 2005
There are many reasons to pick up this book. For me, the reason was: I wanted to learn about Python with a quick, hands-on approach. In other words, show me some code I can punch out quickly; I was looking for some kind of instant gratification. =)

I jumped directly to the Index and looked up Mac OS X (my OS of choice). There I found a few starters. For example, Counting Pages of PDF Documents on Mac OS X. While on the surface not very compelling or all that useful, it does show some native Python integration with the OS X CoreGraphics package - which I wasn't aware of. After running that program (it took me an entire 30 seconds to write and execute) I bounced around the book looking for random cool things to try out.

All the things you would expect to see in the cookbook are there; manipulating files, parsing time and dates, network programming, processing XML, etc, etc, etc. One sections I appreciated was on debugging and testing, however I wish it was larger. It was only 20 pages of the 800 total pages.

I was already comfortable with Perl (Python will look somewhat familiar to Perl programmers) and just had never taken the time to sit down and explore Python. This book was a quick and easy way to get my hands into Python and start learning a new language.
0Comment|5 people found this helpful. Was this review helpful to you?YesNoReport abuse
on January 26, 2006
This book gives the reader a tour of the possibilities of the Python language. Both the Python novice and expert will find the book relevant since newcomers will be exposed to a wide array of things that Python can do, while experts can learn different ways of tackling a problem by looking at somebody else's approach. The book is well written and provides historical insights into Python's evolution. This second edition has a lot more examples in it compared to the first edition. The authors have done a superb job in explaining concepts as opposed to simply presenting listing after listing of Python code. Hence, it makes for a good reference book for the person wanting to dive into Python. The book assumes some knowledge of the Python language, so use it to complement a book that will teach the basics of the language (such as "Learning Python").

In summary, I would highly recommend the book for the person wanting to know the Python language.
0Comment|5 people found this helpful. Was this review helpful to you?YesNoReport abuse
on October 14, 2006
Normally, I'm not a big fan of cookbooks, I find them full of little patterns and quick solutions, but I don't have any desire to read them cover to cover to improve my design and implementation skills. The book Python Cookbook, 2nd Edition is quite different.

After hearing one of the authors, Alex Martelli, talk about object oriented programming at pycon2005 (you can probably find the link on a9) I picked up an electronic copy of his cookbook, through safari, and it has been really helpful to me. I have found it does a very good job of providing both solution with the right level of detail behind so I can improve how I design and code.

So, if you have a slight grasp of python and a problem to solve, this can be quite helpful.
0Comment|5 people found this helpful. Was this review helpful to you?YesNoReport abuse
on June 10, 2005
There is a wealth of information in this book for anyone interested in learning or developing with Python.

Take it from someone who has literally spent hundreds of dollars on computer books - If there were ever a computer book that is worth every cent, this is it.

Even if you are using wxPython don't make the mistake of thinking you will not have to program in Python to make the pretty interface work.

Get a good editor and get this book.

You can thank me in the morning.
0Comment|4 people found this helpful. Was this review helpful to you?YesNoReport abuse
VINE VOICEon June 6, 2007
I'm new to python but not programming. Like a lot of people I had a need to get up to speed really quickly on Python so I purchased several Python books (Learning Python, Python Essential Reference, and this book). What I've found is that once you learn the basics, I find myself using this book much more than the others. It's a great little "cheat". You start with wanting to accomplish something-or-other and simply look it up in the appendex and there is a real good chance you'll find something similar that will at least get you started. The scope that they cover is really impressive, and the examples are simple and to the point. Just what I need. There is not tons of description for each thing, just enough to get you started. This is truly and invaluable resource.
0Comment|3 people found this helpful. Was this review helpful to you?YesNoReport abuse
on April 30, 2005
Python Cookbook Review

Excellent book. The examples are well-written, and are real-world - they present solutions suitable for field use. Of course, like all cookbooks, you may not find the answer in the book. Still, the diversity of solutions is surprising, and, even if it does not cover your particular problem, the book will teach you much about problem solving. The book is especially good at showing the "Python Way" - that is, how to solve problems from a Python perspective, as opposed to how you might solve the problem in Perl or C++.

I would recommend this book to anyone interested in Python.
0Comment|3 people found this helpful. Was this review helpful to you?YesNoReport abuse

Send us feedback

How can we make Amazon Customer Reviews better for you?
Let us know here.