Functional programming design patterns

The presence of higher-order functions in Python allows us to leverage a great many functional programming design patterns. To learn more about these design patterns, a good place to start is the itertools module. The functions in this module provide many examples of how we can write simple functions that do sophisticated processing.

Additionally, we can use some of the features in the functools module. This contains the general-purpose reduce() function. It also contains some functions that can help us write decorators. A decorator, as we'll see in Chapter 13, Metaprogramming and Decorators, is another kind of higher-order function: it's a function that modifies the definition of an original function. This ...

Get Python Essentials 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.