The functional Module
The functional module (introduced in Python 2.5) is intended to eventually supply several interesting functions and types to support functional programming in Python. At the time of writing, there is debate about renaming the module to functools, or perhaps introducing a separate functools module, to hold higher-order functions not strictly connected to the idioms of functional programming (in particular, built-in decorators). However, again at the time of writing, only one function has been definitively accepted for inclusion in the functional module.
partial |
L = map(functional.partial(max, 0), L) as an alternative to the lambda-using snippet: L = map(lambda x: max(0, x), L) and the list-comprehension: L = [max(0, x) for x in L]
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access