Functional Classes

functools.partial()

Bind leading positional arguments and default keyword arguments to a callable. Later keyword arguments override bound keywords.

Formal Syntax & Structure

python syntaxpython
functools.partial(func, /, *args, **keywords)

Parameters & Attributes

NameTypeDescription
funccallableCallable applied by the operation.
argsobjectPositional arguments.
keywordsobjectKeyword arguments.

Return Value

partial

The partial result described above.

Working Example

Example Snippetpython
import functoolssquare = functools.partial(pow, exp=2)print(square(5))
Python Reference