Python Cookbook, 3rd Edition
Recipes for Mastering Python 3
Publisher: O'Reilly Media
Released: May 2013
Pages: 706

If you need help writing programs in Python 3, or want to update older Python 2 code, this book is just the ticket. Packed with practical recipes written and tested with Python 3.3, this unique cookbook is for experienced Python programmers who want to focus on modern tools and idioms.

Inside, you’ll find complete recipes for more than a dozen topics, covering the core Python language as well as tasks common to a wide variety of application domains. Each recipe contains code samples you can use in your projects right away, along with a discussion about how and why the solution works.

Topics include:

  • Data Structures and Algorithms
  • Strings and Text
  • Numbers, Dates, and Times
  • Iterators and Generators
  • Files and I/O
  • Data Encoding and Processing
  • Functions
  • Classes and Objects
  • Metaprogramming
  • Modules and Packages
  • Network and Web Programming
  • Concurrency
  • Utility Scripting and System Administration
  • Testing, Debugging, and Exceptions
  • C Extensions
Table of Contents
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
oreillyPython Cookbook, 3rd Edition
 
4.8

(based on 16 reviews)

Ratings Distribution

  • 5 Stars

     

    (13)

  • 4 Stars

     

    (3)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (0)

  • 1 Stars

     

    (0)

100%

of respondents would recommend this to a friend.

Pros

  • Helpful examples (14)
  • Well-written (13)
  • Accurate (12)
  • Concise (12)
  • Easy to understand (11)

Cons

    Best Uses

    • Intermediate (14)
    • Expert (13)
    • Novice (8)
    • Student (8)
      • Reviewer Profile:
      • Developer (11), Sys admin (6), Educator (3)

    Reviewed by 16 customers

    Sort by

    Displaying reviews 1-10

    Back to top

    Previous | Next »

     
    5.0

    Must have if you are a Python programmer

    By Amit Saha

    from Brisbane, Australia

    About Me Developer, Educator

    Verified Reviewer

    Pros

    • Accurate
    • Concise
    • Easy to understand
    • Helpful examples
    • Well-written

    Cons

      Best Uses

      • Expert
      • Intermediate

      Comments about oreilly Python Cookbook, 3rd Edition:

      I received this book as part of the Blogger review program.

      The book has 15 chapters full of recipes on various aspects of Python ranging from data structures to concurrency and system programming. Authors do a great job and while you won't perhaps benefit from reading this book page to page, but you may certainly as well, since you will most likely learn new things all throughout.

      All in all great book, must have.

       
      5.0

      It is great

      By eavilesmejia

      from Nicaragua

      Verified Reviewer

      Pros

      • Concise
      • Easy to understand
      • Helpful examples

      Cons

        Best Uses

          Comments about oreilly Python Cookbook, 3rd Edition:

          I recommend this book to have a solid learning in python, it use pythonic syntax to resolve the problems.

          (2 of 2 customers found this review helpful)

           
          5.0

          Fantastic Cookbook

          By JimSchubert

          from Seattle WA

          About Me Developer

          Verified Reviewer

          Pros

          • Accurate
          • Concise
          • Easy to understand
          • Helpful examples
          • Well-written

          Cons

            Best Uses

            • Expert
            • Intermediate
            • Novice
            • Student

            Comments about oreilly Python Cookbook, 3rd Edition:

            I read Python Cookbook as part of the O'Reilly Bloggers program. I would highly recommend Python Cookbook to developers with any level of expertise, provided they understand the basic syntax and usage of Python 3.

            I don't use Python regularly. I've stayed away from Python for a while because of the parallel development of the 2.x and 3.x versions of Python. One of the things I loved about this book is that the authors clearly state that the intention of the book is to cover Python 3 only. In fact, many of the recipes won't work in Python 2.x. The book's contents have made me rethink avoiding Python.

            I consider myself somewhat familiar with Python basics, which is required if you want to gain the most from this book. While the book does start of with some simple recipes (like list comprehensions, string manipulations, math operations), it eventually delves more into advanced topics like metaprogramming, socket programming, and the intricacies of working with threads.

            It may not cover extremely advanced topics in Python, but the book comes close. The last chapter discusses interacting with C libraries which you may already have experience with if you've read Gray Hat Python (also available from O'Reilly). I consider language interop a pretty advanced topic.

            In all, I was very pleased with the content and delivery of this book. I generally bookmark one or two pages in a book, but with this book I ended with 12 bookmarked pages. It definitely left me excited about developing applications with Python 3.

            One caveat to readers: some of these recipes are for demonstration purposes only and should not be used in production code. For example, recipe 10.11 shows how you'd load modules from a remote machine using import hooks. Just because you *can* do this, doesn't mean you should.

            (1 of 1 customers found this review helpful)

             
            5.0

            Python Cookbook Review

            By Nerdy Dude

            from Hollis, NH

            About Me Developer

            Verified Reviewer

            Pros

            • Accurate
            • Concise
            • Easy to understand
            • Helpful examples
            • Well-written

            Cons

              Best Uses

              • Intermediate
              • Novice
              • Student

              Comments about oreilly Python Cookbook, 3rd Edition:

              For those learning Python, personally, I would recommend Learning Python by Mark Lutz but as a companion book, this Python Cookbook is wonderful!
              It'll help you learn a little bit about Python if you're starting out but once you get the basics down, the Cookbook series are THE way to go.
              Working with file I/O? This book has a recipe for you. Doing networking? This book has a recipe for you. Need to process through data from various file formats? This book has a recipe for you.
              If anything, look through the TOC to see if there's anything that might be useful and chances are, you'll find it in this book.
              I would definitely recommend this to anyone who uses Python or will be using it more in the future.

              Disclaimer: I received an electronic version of this book because I am a part of the wonderful O'Reilly Blogger Review Program. These are just my opinions of the book.

              (1 of 1 customers found this review helpful)

               
              5.0

              Definitely a must

              By boriel

              from Santa Cruz de Tenerife, ES

              About Me Developer, Sys Admin

              Verified Reviewer

              Pros

              • Accurate
              • Concise
              • Easy to understand
              • Helpful examples
              • Well-written

              Cons

                Best Uses

                • Expert
                • Intermediate

                Comments about oreilly Python Cookbook, 3rd Edition:

                I considered myself an intermediate to expert pythonista, and this book taught me new and exciting techniques almost from the fist page.

                It includes both python 2 and 3 idioms directly applicable to many common patterns I usually did in a suboptimal manner. Compiler and parsers, Python 2 & 3, networking, asynchronous and cooperative multitasking... and everything in a bunch of lines is something definitely recommended for everyone wanting to master python programming.

                I started focusing on some recipes an ended up reading the book from beginning to end.

                Note: This book might not be suitable for novice programmers or python learners.

                (3 of 3 customers found this review helpful)

                 
                5.0

                Python 3: The Power is Yours!

                By Alejandro Cabrera

                from Duluth, GA, USA

                About Me Developer, Educator, Pythonista, Sys Admin

                Verified Reviewer

                Pros

                • Accurate
                • Concise
                • Easy to understand
                • Helpful examples
                • Well-written

                Cons

                  Best Uses

                  • Expert
                  • Intermediate
                  • Novice
                  • Pythonista
                  • Student

                  Comments about oreilly Python Cookbook, 3rd Edition:

                  This book is an amazing resource for making the most of Python 3. This book truly makes it apparent what you're missing out on in the land of Python 2 and shows what can be accomplished more concisely in Python 3.

                  For example, as early as chapter 1, you're introduced to advanced unpacking techniques available in Python 3:

                  head, *tail = elems

                  The equivalent in Python 2 is:

                  head, tail = elems[0], elems[1:]

                  The chapter on generators and iterations techniques alone is worth the price of this book. It shows you how to "Loop Like a Native", all the way through using partial function application combined with lambdas to lazily loop over the contents of a file, ending when there's nothing left to read. Elegant!

                  There's more gems here, but I'll leave them for you to discover. The authors did a wonderful job of putting this book together, and I highly recommend this to anyone interested in becoming an effective Pythonista!

                   
                  4.0

                  Passes the Cookbook Standard

                  By Bluegeek

                  from Taylor, MI

                  About Me Sys Admin

                  Verified Reviewer

                  Pros

                  • Concise
                  • Helpful examples

                  Cons

                    Best Uses

                    • Expert
                    • Intermediate
                    • Novice
                    • Student

                    Comments about oreilly Python Cookbook, 3rd Edition:

                    When I use an O'Reilly "Cookbook", I judge it according to its' usefulness: Can I become productive quickly? Is it easy to find what I need? Does it provide helpful tips? Does it teach me where to find the answers to my questions?

                    This book is not targeted at new Python programmers, but that's where I'm at. The best way for me to learn a new scripting language is to dive right in and try to write something useful, and that was my goal for the "Python Cookbook". I also had "Learning Python" handy to cover any of the basics.

                    My first Python script was written to read in lists of subnets from two separate files and check that every subnet in list B was also in list A.

                    I used Recipe 13.3 to parse the command line options. Recipe 5.1 showed me how to read and write files. Recipe 2.11 taught me how to strip carriage returns out of my lines. Recipe 1.10, "Removing Duplicates from a Sequence while Maintaining Order", was very helpful and I was able to reuse the code in my own script. Recipe 2.14, "Combining and Concatenating Strings", helped me with my print statements. Considering this was the first Python script I ever wrote and that it ran, I consider both it and the "Python Cookbook" a success.

                    I had a bit more trouble with my second script. I was trying to write a script to find the subnet address given an interface address in CIDR notation. Recipe 11.4 introduced the ipaddress module, but this module refused to accept a string variable containing the interface in CIDR notation. I ended up installing another module (netaddr) I found via Google and things went better after that. I suspect the problem was that I was using ActivePython 2.7.2.5 [64 bit] and this book was written for Python 3.

                    As a DNS professional I was disappointed that there were no DNS-related recipes in the Network and Web Programming section, but Web-related topics were well-represented in the book.

                    The "Python Cookbook" doesn't seem to have quite the depth and organization of the "Perl Cookbook" but I'm sure I will rely on it heavily as I learn to use Python. It did allow me to be productive very quickly and it passes the "Cookbook" standard with flying colors. Any book that can get me to the point of writing a working, useful script in less than a day is worth using. I recommend this book to anyone who has a basic understanding of Python and wants to get past "Hello, World" and "Eat Spam" as fast as possible.

                    Reviewer's Note: I am a member of the O'Reilly Blogger Review program and received a free copy of the "Python Cookbook" which was used to write this review.

                     
                    4.0

                    Python Cookbook, 3rd Edition

                    By syko

                    from Hamilton, MT USA

                    About Me Designer, Developer, Sys Admin

                    Verified Reviewer

                    Pros

                    • Accurate
                    • Concise
                    • Easy to understand
                    • Helpful examples
                    • Well-written

                    Cons

                      Best Uses

                      • Expert
                      • Intermediate
                      • Learn Python 3
                      • Novice
                      • Student

                      Comments about oreilly Python Cookbook, 3rd Edition:

                      I am pretty new at programming in Python. So this is my first Python Cookbook. The author(s) say that this is a new/different format for this edition. I like this format very much. While NOT a tutorial, the coded examples (in Python3) have already been of help to me.

                      It reads like much like the BASH Cookbook, with lots of examples broken down into relevant categories. As well as 'what not to do'.

                      From a 'learners' perspective, this is an indispensable resource.

                      (1 of 1 customers found this review helpful)

                       
                      5.0

                      Great cookbook, and so much more..

                      By B^3 Bill

                      from Colorado Springs, CO

                      About Me Designer, Developer, Educator, Maker, Sys Admin, Technologist

                      Verified Reviewer

                      Pros

                      • Accurate
                      • Concise
                      • Easy to understand
                      • Helpful examples
                      • Well-written

                      Cons

                        Best Uses

                        • Expert
                        • Intermediate

                        Comments about oreilly Python Cookbook, 3rd Edition:

                        The breadth & depth of the "recipes" are fantastic; the "Problem", "Solution", "Discussion" format really works. Discussions following most of the recipes are great, providing additional insights on functionality & limitations. A lot of the discussions are longer than the solutions; this lets you get the job done, then go back and gain deeper understanding.

                        The book covers unusual, but very powerful things like memory mapping binary files, high-speed vector processing with numpy, lazy evaluation, cached instances, meta-programming, disassembly, concurrency, and much, much more. All this in-addition-to the daily kinds of things one runs into.

                        As the preface states, it's not an introductory text, but it's great for folks needing or wanting to go deeper.

                         
                        5.0

                        broad coverage of many topics

                        By don

                        from nj

                        Pros

                          Cons

                            Best Uses

                            • Expert
                            • Intermediate
                            • Novice
                            • Student

                            Comments about oreilly Python Cookbook, 3rd Edition:

                            good coverage of Python 3 recipes
                            makes a great complement to the Python reference and library documents

                            Displaying reviews 1-10

                            Back to top

                            Previous | Next »

                             
                            Buy 2 Get 1 Free Free Shipping Guarantee
                            Buying Options
                            Immediate Access - Go Digital what's this?
                            Ebook: $39.99
                            Formats:  DAISY, ePub, Mobi, PDF
                            Print & Ebook: $54.99
                            Print: $49.99