Do you want to take your Python to the next level? Python is easy to learn. You can learn the basics in a day and be productive with it. But there are more advanced constructs that you will eventually run across if you spend enough time with it. Don't be confused by these. Learn them, embrace them, and improve your code and others.
Combines Three Guides into one Book This book is composed of three popular guides:
Guide to: Functional Python & Comprehension Constructs Guide to: Learning Iteration & Generators in Python Guide to: Learning Python Decorators
Write Python code like the masters These constructs, while not necessary per se, allow you to be more succinct, re-use code, and think about code in a different way. You will learn:
How the constructs work When to use them Real life examples from the standard library
Understand other's code This book covers many of these intermediate constructs that are available in Python. The book covers both Python 2 and 3. Topics include:
Functional programming List comprehensions Generator expressions Set & dict comprehensions Iteration Generators Closures Decorators
Based on popular tutorials and sessions I have taught material similar to these constructs at popular tutorials at conferences such as PyCon, OSCON and Strata (and other conferences). This book is based on my experience teaching and using Python for many years. I hope you learn something while in the course of your reading. Maybe it will help you in your next task, code review, or job interview.
I first met Matt Harrison years ago when he gave a great tutorial on decorators and functions at the Southern California Linux Exposition. In less than an hour he managed to get a packed room understanding and writing their own decorators. I took copious notes, and wished there was a book he wrote that I could reference.
Fortunately, this is that book. ;-)
Matt starts with the functional built-ins of Python such as lambda, filter, map, reduce, adds in recursion, then tops it off with list, set, and dict comprehensions. It's great stuff and he explains it well.
The next part of the book delves into iteration and generators. If you know anything about Python's functional capabilities, you know this builds pretty much right off the first part. For me, I found this made the book feel like it built upon itself in a clever, conceptual sort of way.
Finally, the last part is a really nice piece on decorators, which means functions and more functions!
All in all I really liked this book and learned from it. If you have at least a basic understanding of Python and are interested in the language, you owe it to yourself to get this book.
Includes excellent examples with fairly comprehensive explanations for a wide variety of language features. Special care is taken to highlight the differences between Python 2 and Python 3, especially that some of the features which are available in Python2 are sometimes vastly different in behaviour (lazy methods rather than producing sequence upfront), implementation (map as built-in function VS. Built-in class), or location (moved from standard libraries). The only section that could benefit from further elucidation is that of Chapter 14 - Alternate Decorator Implementations.