Intermediate Python Knowledge

Higher-Order Functions in Python — map(), filter(), and reduce()

Understand three commonly used higher-order functions

Yong Cui
The Startup
Published in
7 min readMay 20, 2020

--

Photo by Fonsi Fernández on Unsplash

Although Python is an object-oriented programming language by design, it supports some operations that are more pertinent to the concept of functional programming. But what does functional programming mean exactly? Well, let’s take a quick look at the definition in Wikipedia.

In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions.

From the definition, we can understand that the core of functional programming is its focus on functions. Specifically, this paradigm is primarily to use functions to manipulate and pass data between different components of the program.

One key aspect of the functional style of Python is its treatment of functions as first-class citizens. It simply means that functions are just like other Python objects (e.g., integers, strings, lists, and custom class instances). Related to this is that functions can be passed to other functions as input arguments, and we call those functions that can take other functions as higher-order functions.

--

--

Yong Cui
The Startup

Work at the nexus of biomedicine, data science & mobile dev. Author of Python How-to by Manning (https://www.manning.com/books/python-how-to).