Chapter 4. Functional Programming – Readability Versus Brevity

Python is one of the few (or at least the earliest) nonfunctional languages to incorporate functional features. While Guido van Rossum has tried to remove some of them a few times, they have become ingrained in the Python community, and list comprehensions (dict and set comprehensions soon to follow) are widely used in all sorts of code. The most important thing about code shouldn't be how cool your reduce statement is or how you can fit the entire function in a single line with an incomprehensible list comprehension. Readability counts (once again, PEP20)!

This chapter will show you some of the cool tricks that functional programming in Python gives you, and it will explain some of ...

Get Mastering Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.