Operator Classes
operator.methodcaller()
Build a callable that looks up a named method on its receiver and invokes it with stored arguments. The method is looked up when the resulting callable is invoked.
Formal Syntax & Structure
python syntaxpython
operator.methodcaller(method, /, *args, **kwargs)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| method | str | Name of the method to call. |
| args | object | Positional arguments forwarded to the method or constructor. |
| kwargs | object | Keyword arguments forwarded to the method or constructor. |
Return Value
callable
The callable result described above.
Working Example
Example Snippetpython
import operatorprint(operator.methodcaller("replace","-","_")("a-b"))