Guide To: Functional Python & Comprehension Constructs

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 beproductive with it. But there are more advanced constructs that youwill 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.Functional Programming and ComprehensionsFunctional programming is a somewhat hidden aspect of Python. Though it supports many of the functional constructs, the style is not widely adopted.On the flip side functional programming appears to be making a resurgence, because of the benefits it can provide. Comprehensions are an alternative Pythonic construct for programming in a similar manner.These are features of Python that are commonly used instead of their functional counterparts. This book covers:List ComprehensionsGenerator ExpressionsSet ComprehensionsDict ComprehensionsWrite Python code like the mastersThese 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 workWhen to use themReal life examples from the standard libraryUnderstand other's codeThis 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 comprehensionsGenerator expressionsSet & dict comprehensions 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 otherconferences). This book is based on my experience teaching and usingPython for many years. I hope you learn something while in the courseof your reading. Maybe it will help you in your next task, codereview, or job interview. Up Your Advanced Python SkillsIt is assumed that the reader has some knowledge of Python. You will walk away knowing the functional constructs, when to use them, how to use them, and when to use their Pythonic counterparts. The functional aspects will aid in grokking Python, Lisps, and other newer languages such as Clojure and Scala.

Author: Matt Harrison

Learn more