Python Cookbook and over 360,000 other books are available for Amazon Kindle – Amazon’s new wireless reading device. Learn more

 

or
Sign in to turn on 1-Click ordering.
 
 
Express Checkout with PayPhrase
What's this? | Create PayPhrase
More Buying Choices
36 used & new from $4.25

Have one to sell? Sell yours here
 
   
Python Cookbook
 
 
Start reading Python Cookbook on your Kindle in under a minute.

Don’t have a Kindle? Get your Kindle here.
 
  

Python Cookbook (Paperback)

~ (Editor), (Editor)
4.3 out of 5 stars  See all reviews (42 customer reviews)

List Price: $39.95
Price: $30.36 & this item ships for FREE with Super Saver Shipping. Details
You Save: $9.59 (24%)
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Usually ships within 6 to 7 days.
Ships from and sold by Amazon.com. Gift-wrap available.

14 new from $12.95 22 used from $4.25

Formats

Amazon Price New from Used from
  Kindle Edition, March 18, 2005 $26.38 -- --
  Paperback, July 14, 2002 $30.36 $12.95 $4.25
There is a newer edition of this item:
Python Cookbook Python Cookbook 4.3 out of 5 stars (42)
$32.97
In Stock.
What Do Customers Ultimately Buy After Viewing This Item?

Frequently Bought Together

Python Cookbook + Learning Python (Animal Guide) + Programming Python
  • This item: Python Cookbook by Anna Martelli Ravenscroft

    Usually ships within 6 to 7 days.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details

  • Learning Python (Animal Guide) by David Ascher

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details

  • Programming Python by Mark Lutz

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details


Customers Who Bought This Item Also Bought

Programming Python

Programming Python

by Mark Lutz
4.1 out of 5 stars (9)  $37.79
Python in a Nutshell, Second Edition (In a Nutshell (O'Reilly))

Python in a Nutshell, Second Edition (In a Nutshell (O'Reilly))

by Alex Martelli
4.5 out of 5 stars (40)  $26.39
Python Pocket Reference (Python in Your Pocket)

Python Pocket Reference (Python in Your Pocket)

by Mark Lutz
3.9 out of 5 stars (16)  $10.19
Python Essential Reference (4th Edition)

Python Essential Reference (4th Edition)

by David M. Beazley
5.0 out of 5 stars (5)  $29.69
Foundations of Python Network Programming

Foundations of Python Network Programming

by John Goerzen
4.7 out of 5 stars (16)  $36.51
Explore similar items

Editorial Reviews

Review

"I have no reservations recommending this book." - Tim Penhey, Cvu, February 2003


Product Description

The Python Cookbook is a collection of problems, solutions, and practical examples for Python programmers, written by Python programmers. The recipes range from simple tasks, such as working with dictionaries and list comprehensions, to entire modules that demonstrate templating systems and network monitoring. The book contains over two hundred recipes for searching and sorting, text manipulation, working with files, threads, and databases, object oriented programming, XML processing, network programming, system administration, and much more. This book is a treasure trove of useful code for all Python programmers, from novices to advanced practitioners, with contributions from such Python luminaries as Guido Van Rossum, David Ascher, Tim Peters, Paul Prescod, Mark Hammond, and Alex Martelli, as well as over one hundred other Python programmers. The recipes highlight Python best practices and can be used directly in day-to-day programming tasks, as a source of ideas, or as a way to learn more about Python.

Product Details

  • Paperback: 606 pages
  • Publisher: O'Reilly Media; 1 edition (July 15, 2002)
  • Language: English
  • ISBN-10: 0596001673
  • ISBN-13: 978-0596001674
  • Product Dimensions: 3.3 x 3.2 x 0.5 inches
  • Shipping Weight: 5.6 ounces (View shipping rates and policies)
  • Average Customer Review: 4.3 out of 5 stars  See all reviews (42 customer reviews)
  • Amazon.com Sales Rank: #657,442 in Books (See Bestsellers in Books)

    Popular in this category: (What's this?)

    #91 in  Books > Computers & Internet > Programming > Languages & Tools > Python

More About the Authors

Discover books, learn about writers, read author blogs, and more.

Look Inside This Book


Tags Customers Associate with This Product

 (What's this?)
Click on a tag to find related items, discussions, and people.
 
(1)

Your tags: Add your first tag
 

 

Customer Reviews

42 Reviews
5 star:
 (24)
4 star:
 (12)
3 star:
 (3)
2 star:
 (2)
1 star:
 (1)
 
 
 
 
 
Average Customer Review
4.3 out of 5 stars (42 customer reviews)
 
 
 
 
Share your thoughts with other customers:
Most Helpful Customer Reviews

 
52 of 56 people found the following review helpful:
3.0 out of 5 stars Half-cooked, September 6, 2005
By Michael Palmer (Waterloo, Ontario Canada) - See all my reviews
(REAL NAME)   
This review is from: Python Cookbook (Paperback)
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.

Comment Comment (1) | Permalink | Was this review helpful to you? Yes No (Report this)



 
74 of 89 people found the following review helpful:
5.0 out of 5 stars Valuable tricks&tips from _real_ Python experts, October 11, 2002
By Alessandro Bottoni (Ferrara Italy) - See all my reviews
Of the many successes of Python, this is the least known but one of the most impressive: it has gained the affection and the respect of a hard guy like Alex Martelli. That is not an easy task for a small, interpreted programming language like Python.

When I first met Alex Martelli, at Think3, he was one of the oldest and most experienced programmers of the company, a programmer who had already used most of the existing languages and had used these languages for the development of large and complex applications, the kind of projects that took months or years to complete. He knew Perl very, _very_ well and was used to rely on a robust, elegant and sophisticated language like C++ for the development of his applications (like Think3's Thinkdesign, a very complex 3D CAD program). He was writing a _lot_ of software, using a large array of different languages and tools. He was a well respected internal consultant at Think3, charged to solve difficult problems related to the software architecture of the program being developed. He was not an easy guy to impress with "yet another small language".

Despite this, Python has gained some room in his heart. I consider this fact as one of the most significant success of this elegant and powerfull language. To be completely honest, I'm not completely surprised by this ending.

Alex Martelli is the kind of scientist and professional that appreciate elegance, wherever he can see it. The taste for elegance, the ability to take pleasure in elegance, is an important part of the scientist and engineer personality. It is hard to be a really good software professional without having any kind of interest for elegance. When you need a simple tool that can face complex problems, you are asking for elegance. When you need a language that leave you with maintenable code, you are asking for elegance. When you want a single language for a wide array of applications, you are asking for elegance. Python can supply you with all the elegance you can ever ask for.

Alex's and David's book is a collection of good techniques that you can use to face a large set of problems with Python, from text transformation to GUI building to OpenGL grahics. You will not find here an introductory book, rather you will find a good second-reading book, the kind of book that can take you from the beginner level to the advanced. It is also the kind of book that can widen your knowledge of the Python world, showing you how this modern language can easily deal with problems that you usually face with C++ or the like.

If you are looking for an introductory book, buy "Learning Python" by Mark Lutz and David Ascher: it is the best one for this task. If you already know Python, buy this book and see how much you still do not know about it.

Comment Comment | Permalink | Was this review helpful to you? Yes No (Report this)



 
22 of 25 people found the following review helpful:
5.0 out of 5 stars Perfect, October 15, 2002
By "neurorat" (Florida, USA) - See all my reviews
This is one of those rare books that is all meat and no fat. It is a wonderful collection of relevant and useful solutions for many programming problems that you will face, and many that you probably just figured were too hard to solve. It is clearly laid out, so finding a needed solution is easy.

One of the most powerful benefits of owning this book is astonishing amount of knowledge you can pick up by browsing it. With almost every recipe I discovered either a new approach to doing something with Python, that was far more elegant than what I would have thought of, or something that I didn't even consider was possible. It covers a vast array of important topics, from text processing, threads, object-oriented programming, and much more.

In short buy this book, grab a drink, and have a nice long sit-down session with it. You'll love every page of it.

Comment Comment | Permalink | Was this review helpful to you? Yes No (Report this)


Share your thoughts with other customers: Create your own review
 
 
 
Most Recent Customer Reviews

3.0 out of 5 stars Out of date. Not very useful.
This book is in need of an update for Python 2.6/3.0 syntax. It covers the "new" Python 2.4.

I bought the book for a project in Python at work, but I never even... Read more
Published 7 months ago by G. Norton

5.0 out of 5 stars Very useful book to see how to best address everyday problems
This is not a learning book, nor a reference book. It is a book that contains "recipes", descriptions of how to perform everyday issues, such as reading a file, sorting a... Read more
Published 8 months ago by David Alan Tussey

2.0 out of 5 stars Go to the website
I bought this book when Python was relatively young and it definitely got the job done on more than a few occasions. Read more
Published 9 months ago by James J. Wiley

5.0 out of 5 stars Good Cookbook
I started reading through the Python Cookbook as a beginner with very little experience in Python but fluent in several other languages ranging from Object Oriented to Functional... Read more
Published 9 months ago by Andrei Mouravski

5.0 out of 5 stars Invaluable
There are so many tricks to be learned here that you can use for either mundane tasks or for more advanced uses of python.
Published 11 months ago by J. Baker

5.0 out of 5 stars i cook a lot
and I find great recipes in this book almost everyday to make my code cleaner and faster.
Published 14 months ago by J. Ramos

3.0 out of 5 stars Good idea book
I like this book for two reasons. 1) If I need to get an idea on how to do something that is not necessarily obvious then it is a good place to look 2) If I have done something... Read more
Published 20 months ago by RF RDC

5.0 out of 5 stars Worth the money
This is the only Python book I've seen to date which provides detailed and practical examples of metaprogramming idioms, and it gets five stars for that chapter way in the back... Read more
Published 20 months ago by orangekay

4.0 out of 5 stars A great edition
This edition (2) is significantly expanded -- and modified where Python advances warrant it -- from the previous version. Read more
Published 21 months ago by Justin Hanekom

2.0 out of 5 stars Not the latest Version
I purchased this for my son as he requested it. It was an older version so he would not be able to use it. He ordered the newer one out. Read more
Published 22 months ago by Susan Griffin

Only search this product's reviews



Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
Topic:
First post:
Prompts for sign-in
 

Search Customer Discussions
Search all Amazon discussions
   



So You'd Like to...


Create a guide

Product Information from the Amapedia Community

Beta (What's this?)


Look for Similar Items by Category


Look for Similar Items by Subject

 

Feedback

If you need help or have a question for Customer Service, contact us.
 Would you like to update product info or give feedback on images?
Is there any other feedback you would like to provide?

Your comments can help make our site better for everyone.


Your Recent History

 (What's this?)

After viewing product detail pages or search results, look here to find an easy way to navigate back to pages you are interested in.