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
| Name | Type | Description |
|---|---|---|
| func | callable | Callable applied by the operation. |
| args | object | Positional arguments. |
| keywords | object | Keyword 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))