💾 Archived View for tris.fyi › pydoc › _functools captured on 2023-01-29 at 02:38:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-01-08)
-=-=-=-=-=-=-
Tools that operate on functions.
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
args = <member 'args' of 'functools.partial' objects> tuple of arguments to future partial calls
func = <member 'func' of 'functools.partial' objects> function object to use in future partial calls
keywords = <member 'keywords' of 'functools.partial' objects> dictionary of keyword arguments to future partial calls
cmp_to_key(...) Convert a cmp= function into a key= function.
reduce(...) reduce(function, iterable[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence or iterable, from left to right, so as to reduce the iterable to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the iterable in the calculation, and serves as a default when the iterable is empty.