Functional Classes

functools.partialmethod()

Define a method with arguments prebound while preserving normal instance binding. Use it on a class rather than as an ordinary function wrapper.

Formal Syntax & Structure

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

Parameters & Attributes

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

Return Value

descriptor

The descriptor result described above.

Working Example

Example Snippetpython
import functoolsclass C: def multiply(self,a,b): return a*b double=functools.partialmethod(multiply,2)print(C().double(4))
Python Reference