On this page
  1. operator.methodcaller
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

operator.methodcaller

Prev: operator.ixor | Up: operator
Rel: operator.abs, operator.add, operator.and_, operator.attrgetter
Ref: docs.python.org — operator.methodcaller
Tags: #public #python3 #stdlib #operator


Import

import operator
from operator import methodcaller

Signature & Overview

operator.methodcaller(name, /, *args, **kwargs)

Return a callable object that calls the given method on its operand.

Usage

import operator

words = ["  hi ", " bye  "]
assert list(map(operator.methodcaller("strip"), words)) == ["hi", "bye"]

Gotchas

REPL Inspect

from operator import methodcaller
help(methodcaller)

Linked from

Related notes