Python Functools Module
Published May 4, 2022Updated Oct 14, 2022
Contribute to Docs
The functools module contains functions that support a functional programming approach in Python.
The following functions are provided by this module.
Functools Module
- cmp-to-key()
- Converts an old-style comparison function into a key function, which will be used as the key argument in functions that accept this parameter.
- reduce()
- Returns an aggregated value that results from the application of a passed function to each item in an iterable.
- singledispatch()
- Turn a function into a single-dispatch generic function, allowing different implementations to be registered based on the type of the first argument.
- total_ordering()
- Generates missing comparison methods in a class based on a minimal set of defined ones.
- update_wrapper()
- Updates a wrapper function to look like the wrapped function by copying attributes like `__name__`, `__doc__`, and `__module__`.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours