Programming Books C Java PHP Python Learn more Browse Programming Books

Sorry, this item is not available in
Image not available for
Image not available

To view this video download Flash Player

Have one to sell? Sell yours here
Tell the Publisher!
I'd like to read this book on Kindle

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Python in a Nutshell [Paperback]

Alex Martelli
4.5 out of 5 stars  See all reviews (26 customer reviews)

Available from these sellers.

Free Two-Day Shipping for College Students with Amazon Student

Shop the new
New! Introducing the, a hub for Software Developers and Architects, Networking Administrators, TPMs, and other technology professionals to find highly-rated and highly-relevant career resources. Shop books on programming and big data, or read this week's blog posts by authors and thought-leaders in the tech industry. > Shop now
There is a newer edition of this item:
Python in a Nutshell, Second Edition (In a Nutshell) Python in a Nutshell, Second Edition (In a Nutshell) 4.5 out of 5 stars (25)
In Stock.

Book Description

March 2003 0596001886 978-0596001889 1st

Ask any Python aficionado and you'll hear that Python programmers have it all: an elegant language that offers object-oriented programming support, a readable, maintainable syntax, integration with C components, and an enormous collection of precoded standard library and extension modules. Moreover, Python is easy to learn but powerful enough to take on the most ambitious programming challenges. But what Python programmers have lacked is one concise and clear reference resource, with the appropriate measure of guidance in how best to use Python's great power. Now Python in a Nutshell fills this need.

In the tradition of O'Reilly's "In a Nutshell" series, this book offers Python programmers one place to look when they need help remembering or deciphering the syntax of this open source language and its many modules. This comprehensive reference guide makes it easy to look up all the most frequently needed information--not just about the Python language itself, but also the most frequently used parts of the standard library and the most important third-party extensions.

Python in a Nutshell focuses on Python 2.2 (and all its point releases), currently the most stable and widespread Python release. This book includes:

  • A fast-paced tutorial on the syntax of the Python language itself
  • An explanation of object-oriented programming in Python, covering both the classic and new-style object models
  • Coverage of other core topics, including exceptions, modules, strings, and regular expressions
  • A quick reference for Python's built-in types and functions, as well as the key modules in the Python standard library, including sys, os, time, thread, math, and socket, among many others
  • Reference material on important third-party extensions, such as Numeric and Tkinter
  • Information about extending Python and embedding it into other applications
Python in a Nutshell provides a solid, no-nonsense quick reference to information that programmers rely on the most. This latest addition to the best-selling "In a Nutshell" series will immediately earn its place in any Python programmer's library.

Editorial Reviews


"Brave beginners will be well served by this title, which provides an intelligent, fast paced intro to core topics." - Martin Howse, LinuxUser & Developer, Issue 30 "I whole-heartedly recommend this book to all Python programmers. It is a very concise and informative book, and its small size belies its information content. I would also recommend and suggest this book to any experienced programmers wishing to begin programming in Python, who would enjoy a straight-to-the-point manual on the Python language." - Daire Stockdale, Cvu/ACCU

About the Author

Alex Martelli spent 8 years with IBM Research, winning three Outstanding Technical Achievement Awards. He then spent 13 as a Senior Software Consultant at think3 inc, developing libraries, network protocols, GUI engines, event frameworks, and web access frontends. He has also taught programming languages, development methods, and numerical computing at Ferrara University and other venues. He's a C++ MVP for Brainbench, and a member of the Python Software Foundation. He currently works for AB Strakt, a Python-centered software house in Gteborg, Sweden, mostly by telecommuting from his home in Bologna, Italy. Alex's proudest achievement is the articles that appeared in Bridge World (January/February 2000), which were hailed as giant steps towards solving issues that had haunted contract bridge theoreticians for decades.

Product Details

  • Series: In a Nutshell (O'Reilly)
  • Paperback: 600 pages
  • Publisher: O'Reilly Media; 1st edition (March 2003)
  • Language: English
  • ISBN-10: 0596001886
  • ISBN-13: 978-0596001889
  • Product Dimensions: 8.9 x 6 x 1.1 inches
  • Shipping Weight: 1.8 pounds
  • Average Customer Review: 4.5 out of 5 stars  See all reviews (26 customer reviews)
  • Amazon Best Sellers Rank: #561,879 in Books (See Top 100 in Books)

More About the Author

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

Customer Reviews

Most Helpful Customer Reviews
100 of 101 people found the following review helpful
4.0 out of 5 stars Nutshell v. Online Docs (2nd edition too) March 8, 2004
By C. Dunn
This is a great book, without question. The question is whether it is worth the price, given the free online HTML reference documentation.

+ Very good index; somewhat better than the online index.
+ Helpful explanations.
+ Some examples.
+ Much more advice than the online docs.
+ Very nice typesetting.

Cons (1st edition):
- Does not cover some of the most useful (new) modules: timeit, logging, zipimport, itertools, sets, sum, heapq.
- In particular, I would love to have ADVICE on how to use logging effectively.
- DOES cover the dead (insecure) modules rexec and Bastion.

So take your own decision. Personally, I would say it's not essential, but still worth the price. I go back and forth between the online index and this book.


The 2nd edition covers most of Python2.5. (The 1st covered 2.2 and much of 2.3). It includes most useful modules and excludes the deprecated ones, so it actually adds much more info than its slight increase in page-count would indicate. The only thing I was not able to find was 'meta_path', which is at least mentioned as highly technical.

In general, the 2nd edition is for a more expert user than the 1st. The explanations sometimes include some dense code:

* There is a long example of using meta-classes.
* The explanation of the new try/except/finally assumes that you understand the old (broken) behavior.
* The 'with' statement is explained by way of an equivalent fragment of code.

These changes make the 2nd edition ideal for the practicing Python programmer. However, a novice might be intimidated.

I would now increase the rating to 5 stars if I could. Excellent reference work!
Was this review helpful to you?
59 of 62 people found the following review helpful
5.0 out of 5 stars A Classic Book April 16, 2003
Python in a Nutshell, by Alex Martelli, 2003 O'Reilly, 636 pages.
Perhaps the best book about Python ever written, this book is the perfect capstone to anyone's library of Pythonic books, and also the perfect introduction to Python for anyone well versed in other programming languages. For newbies to programming, this would still be a good second book after a good introductory book on Python, such as Learning Python by Mark Lutz.
Written by my favorite author and Pythonista, Alex Martelli, this book manages to fill three roles in extremely pleasing fashion. First and foremost to me, it is a great read, straight through. Mr. Martelli's prose is always sparkling and always keeps the reader interested. No matter how many Python books you have read, you will learn some nuances from this book, and it is about the best review of the whole Pythonic subject matter that I can imagine. While there is absolutely no fluff whatsoever in these 636 pages, it still makes for rather easy reading because the explanations are so clearly thought out and explored as to lead one gently to understanding, without in any way being verbose. It is obvious that Alex Martelli took his time and put in sufficient thought, effort, and intellectual elbow-grease to make this work a classic for all time.
Secondly, this book is the ultimate Pythonic reference book, the best fit to this role I have yet seen. You will keep this book in the most cherished spot on your book shelf, or else right at your side on your computer desk, because you can almost instantly find any topic on which you need to brush up, in the midst of a programminng project.
Read more ›
Comment | 
Was this review helpful to you?
27 of 28 people found the following review helpful
I bought this book at the PyCon 2003 Python conference mainly to complete my Python book collection. I thought that since it was a Nutshell book and I already knew a ton about Python (I am an official developer on the language) that I wouldn't really pick up that much.
I was wrong. Not only did I learn some new things, but Alex's wonderful way of presenting ideas helped clarify and present a different view of some vital concepts in Python that made them even easier to grasp than I had originally thought. There is a reason why he is called the Martellibot on comp.lang.python and the python-dev mailing list.
I also have a friend who is a programmer who has read the first chapter or so of the book and has also found it a great way to learn Python.
So whether you are a hardened Python programmer or just starting out (as long as you can already program), this book is definitely worth the money. And the Python Cookbook makes a great companion book to this to pick up a few tricks and get even more example code to learn from (especially from my contributed recipes to the book =).
Comment | 
Was this review helpful to you?
48 of 58 people found the following review helpful
3.0 out of 5 stars For professionals only January 17, 2004
Format:Paperback|Verified Purchase
Let me begin this review with a fair warning: this book is NOT for fresh programmers, hobbyists, system admins and other non-professional programmers out there, looking for a book that will actually help them LEARN Python language (even if the book has 4+ stars, it's still the O'Reilly Nutshell book).
(Btw. I know that, because I fit in all previously mentioned categories :-).
This book is (as title suggest) a QUICK reference of the Python language written by very competent author, I have no second thought about that, for already competent Python programmers that need good reference manual at hand.
I dare to say, that terse writing style, lack of examples and hard to follow explanations on some topics (without clear and simple code examples) will put off most of the new or intermediate programmers.
In my humble opinion this book is short for 200+ pages dedicated exclusively to code samples - I think examples in any reference book are as important as syntax and language explanations.
If you're already experienced programmer then you'll be more than satisfied with this book, just go ahead an click the button. If you're, on the other hand, starting to learn Python and need a good learning guide, I would recommend, that you begin with the book "Learning Python, 2 Edition" from O'Reilly.
Was this review helpful to you?
Most Recent Customer Reviews
5.0 out of 5 stars Best reference for Python
This is simply the best reference book for Python.

As a reference book it not suitable for learning Python from scratch, even if there is a not-so-short introduction to... Read more
Published on January 9, 2008 by Alessandro Ferretti
5.0 out of 5 stars Simply the best generalist reference for the medium/advanced Python...
Nutshell is rather dry reading and provides very little of the usual user-friendly introductions to language features by solving simple problems. Read more
Published on December 5, 2007 by WiltDurkey
5.0 out of 5 stars Watch for second edition
This first edition is probably not where you want to invest your dollars. The second edition (ISBN 0596100469 ) is projected to be out this month (July 2006) and will cover not... Read more
Published on July 11, 2006 by Richard Pinneau
4.0 out of 5 stars Good book to learn and as a reference
For someone who knows other programming languages this is a great book to quickly get a feel for the language and to start trying it out. The book only covers up to Python 2. Read more
Published on March 30, 2006 by Christian
5.0 out of 5 stars Excellent
All what you would expect from the title : very complete even if not exhaustive coverage of the language and its main libraries, excellent explanations... Read more
Published on August 30, 2005 by Thierry Chevalier
5.0 out of 5 stars For the experienced Pythoneer wanting more detail
Python in a nutshell is an excellent reference for the experienced Python programmer. Alex Martelli does a wonderful job focusing on the book's goal of being a concise reference to... Read more
Published on June 10, 2005 by Eric Walstad
5.0 out of 5 stars Best Distillation of Python Anwhere
I bought this book after working through Learning Python by Lutz and Ascher, and reading sections of other books. It is now my #1 reference. Read more
Published on December 15, 2004 by David MacQuigg
4.0 out of 5 stars very useful reference
I've made a complete switch to Python from Perl, and this book has been a very, very helpful resource in doing so. Read more
Published on July 23, 2004 by ohmysohopeless
3.0 out of 5 stars Can't be definitive....
I expected this to be as comprehensive as the Java in a Nutshell books (i.e., to cover all standard modules/functions). Read more
Published on April 23, 2004
4.0 out of 5 stars Great Reading
I admit I had a hard time getting started with this book but found it to be quite interesting.
Published on January 2, 2004 by Lynde Ricciardelli
Search Customer Reviews
Search these reviews only

What Other Items Do Customers Buy After Viewing This Item?

Sell a Digital Version of This Book in the Kindle Store

If you are a publisher or author and hold the digital rights to a book, you can sell a digital version of it in our Kindle Store. Learn more


There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
First post:
Prompts for sign-in

Look for Similar Items by Category