PyMOTW: functools
Originally posted
· 1 min read
The functools
module includes tools for wrapping functions and other callable objects.
The primary tool supplied by the functools
module is the class partial
, which can be used to “wrap” a callable with default arguments. The resulting object is itself callable and can be treated as though it is the original function. It takes all of the same arguments as the original callable and can be invoked with extra positional or named arguments as well.