operator.methodcaller()
operator.methodcaller() is a Python function in the Operator Module category. Returns a callable that calls a method by name on its operand. The syntax is operator.methodcaller(name, /, *args, **kwargs). Returns: Callable. A typical example: from operator import methodcaller
uppercase = methodcaller("upper")
uppercase("hello") # "HELLO". A close sibling is operator.add(), which returns a + b (addition). Useful with reduce and map. A close sibling is operator.sub(), which returns a - b (subtraction). A close sibling is operator.mul(), which returns a * b (multiplication). A close sibling is operator.itemgetter(), which returns a callable that fetches the specified item(s) from its operand. More about this category: Operator functions — add, mul, itemgetter, attrgetter, methodcaller. Related Operator Module entries: operator.add(), operator.sub(), operator.mul(), operator.itemgetter(), operator.attrgetter(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.