Join Amazon Prime and ship Two-Day for free and Overnight for $3.99. Already a member? Sign in.
Python Cookbook and over 300,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.
 
 
More Buying Choices
55 used & new from $22.98

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 yours here.
 
  
4.3 out of 5 stars See all reviews (42 customer reviews)

List Price: $49.95
Price: $32.97 & this item ships for FREE with Super Saver Shipping. Details
You Save: $16.98 (34%)
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
In Stock.
Ships from and sold by Amazon.com. Gift-wrap available.

Want it delivered Monday, July 20? Choose One-Day Shipping at checkout. Details
34 new from $27.17 21 used from $22.98
Also Available in: List Price: Our Price: Other Offers:
Kindle Edition (Kindle Book) $29.67
Paperback (1) 35 used & new from $11.65
Digital (Download: PDF) $39.99 $39.99
Like this book? Find similar titles from O'Reilly and Partners in our O'Reilly Bookstore.

Frequently Bought Together

Python Cookbook + Learning Python, 3rd Edition + Python in a Nutshell, Second Edition (In a Nutshell (O'Reilly))
Price For All Three: $85.75

Show availability and shipping details


Customers Who Bought This Item Also Bought

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
Programming Python

Programming Python

by Mark Lutz
4.0 out of 5 stars (7)  $37.79
Python Pocket Reference (Pocket Reference (O'Reilly))

Python Pocket Reference (Pocket Reference (O'Reilly))

by Mark Lutz
3.8 out of 5 stars (14)  $9.95
Python Essential Reference (4th Edition) (Developer's Library)

Python Essential Reference (4th Edition) (Developer's Library)

by David M. Beazley
4.6 out of 5 stars (70)  $29.69
Core Python Programming (2nd Edition) (Core Series)

Core Python Programming (2nd Edition) (Core Series)

by Wesley Chun
4.1 out of 5 stars (36)  $37.79
Explore similar items

Editorial Reviews

Review
"I have no reservations recommending this book." - Tim Penhey, Cvu, February 2003 --This text refers to an out of print or unavailable edition of this title.

Product Description
Portable, powerful, and a breeze to use, Python is the popular open source object-oriented programming language used for both standalone programs and scripting applications. It is now being used by an increasing number of major organizations, including NASA and Google.

Updated for Python 2.4, The "Python Cookbook," 2nd Edition offers a wealth of useful code for all Python programmers, not just advanced practitioners. Like its predecessor, the new edition provides solutions to problems that Python programmers face everyday.

It now includes over 200 recipes that range from simple tasks, such as working with dictionaries and list comprehensions, to complex tasks, such as monitoring a network and building a templating system. This revised version also includes new chapters on topics such as time, money, and metaprogramming.

Here's a list of additional topics covered:

Manipulating text

Searching and sorting

Working with files and the filesystem

Object-oriented programming

Dealing with threads and processes

System administration

Interacting with databases

Creating user interfaces

Network and web programming

Processing XML

Distributed programming

Debugging and testing

Another advantage of The "Python Cookbook," 2nd Edition is its trio of authors--three well-known Python programming experts, who are highly visible on email lists and in newsgroups, and speak often at Python conferences.

With scores of practical examples and pertinent background information, The "Python Cookbook," 2nd Edition is the one source you need if you're looking to build efficient, flexible, scalable, and well-integrated systems.

See all Editorial Reviews


Product Details

  • Paperback: 844 pages
  • Publisher: O'Reilly Media, Inc.; 2 edition (March 18, 2005)
  • Language: English
  • ISBN-10: 0596007973
  • ISBN-13: 978-0596007973
  • Product Dimensions: 9 x 7 x 1.8 inches
  • Shipping Weight: 2.5 pounds (View shipping rates and policies)
  • Average Customer Review: 4.3 out of 5 stars See all reviews (42 customer reviews)
  • Amazon.com Sales Rank: #19,133 in Books (See Bestsellers in Books)

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

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

Inside This Book (learn more)


What Do Customers Ultimately Buy After Viewing This Item?


Tags Customers Associate with This Product

 (What's this?)
Click on a tag to find related items, discussions, and people.
Check the boxes next to the tags you consider relevant or enter your own tags in the field below.
(28)
(5)
(1)

Your tags: Add your first tag
 
Help others find this product — tag it for Amazon search
No one has tagged this product for Amazon search yet. Why not be the first to suggest a search for which it should appear?

 

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

 
45 of 48 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)   
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)



 
72 of 86 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
This review is from: Python Cookbook (Paperback)
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)



 
20 of 23 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 review is from: Python Cookbook (Paperback)
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 3 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 4 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 4 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 5 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 6 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 10 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 16 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 16 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 16 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 18 months ago by Susan Griffin

Only search this product's reviews



Customer Discussions

 Beta (What's this?)
New! See all customer communities, and bookmark your communities to keep track of them.
This product's forum (0 discussions)
  Discussion Replies Latest Post
  No discussions yet

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


Active discussions in related forums
   


Product Information from the Amapedia Community

Beta (What's this?)


So You'd Like to...

Create a guide

Look for Similar Items by Category


Let Toro Clear the Snow

Let Toro Clear the Snow
Rely on Toro for top-quality snow throwers and power shovels to make snow removal a breeze.

Shop all Toro

 

Big Savings in Books

Bargain Books
Find great titles at fantastic prices in our Bargain Books Store.
 

Buy Three Books, Get a Fourth Free

4-for-3 Books
Order any four eligible books under $10 and get the lowest-price book free in our 4-for-3 Books Store. See more details.
 

Best Books

Best of the Month
See our editors' picks and more of the best new books on our Best of the Month page.
 

 

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.


Where's My Stuff?

Shipping & Returns

Need Help?

Your Recent History

  (What's this?)
You have no recently viewed items or searches.

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

Look to the right column to find helpful suggestions for your shopping session.

Continue shopping: Top Sellers
Free
Free by Chris Anderson
$0.00
Paranoia
Paranoia by Joseph Finder
$0.00
My Soul to Lose
My Soul to Lose by Rachel Vincent
Glenn Beck's Common Sense
Glenn Beck's Common Sense by Glenn Beck
$6.59

Conditions of Use | Privacy Notice © 1996-2009, Amazon.com, Inc. or its affiliates