September 2026
1051 pages
35h 4m
English
The functools module of the standard library contains functions and decorators that can be used to modify callable objects, such as functions or methods, at an abstract level. This section describes how you can simplify interfaces, add a cache, and complete an ordering of custom classes.
The functools module contains the partial function, which can be used to simplify function interfaces. To do this, let’s take a look at the following function:
def f(a, b, c, d): print(f"{a} {b} {c} {d}")
The f function expects many parameters—four, to be precise. Now let’s imagine we have to call the f function very often in the program and always pass the same values for the b, c, and ...
Read now
Unlock full access