💾 Archived View for tris.fyi › pydoc › _functools captured on 2023-04-26 at 13:17:31. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
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.