On this page
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
- Supports preset method args:
operator.methodcaller("split", ",")callsobj.split(",").
REPL Inspect
from operator import methodcaller
help(methodcaller)
Linked from
Related notes
- tuts/python3/stdlib_module/operator/ixor Linked here; links to this page; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/operator/abs Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/add Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/and_ Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/attrgetter Linked here; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/call shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/concat shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/contains shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/countOf shared tags: #operator, #stdlib