Skip Navigation

A Guide to Python Lambda Functions

adamj.eu A Guide to Python Lambda Functions - Adam Johnson

In Python, Lambda functions are rare compared to “normal” functions, and occasionally misunderstood or overused.

A Guide to Python Lambda Functions - Adam Johnson
8

You're viewing a single thread.

8 comments
  • I discover the operator module! Amazing! 🤩

    The operator Module A third alternative to writing lambda functions is to use the standard library’s operator module. This module contains some predefined functions and function factories, which can replace the most common use cases for lambda functions. Let’s look at both of these separtaely, factories first. Another note: the function that attrgetter returns is implemented in C, so it’s slightly faster than using either a normal or lambda function.

    Useful if you want to speed up your code.

8 comments