Operator Classes

operator.itemgetter()

Build a callable that retrieves one item or a tuple of items using subscription. Supports mapping keys, indices and slices when the receiver supports them.

Formal Syntax & Structure

python syntaxpython
operator.itemgetter(item, /, *items)

Parameters & Attributes

NameTypeDescription
itemobjectItem to select or search for.
itemsobjectAdditional item keys or indices.

Return Value

callable

The callable result described above.

Working Example

Example Snippetpython
import operatorprint(operator.itemgetter(2,0)([10,20,30]))
Python Reference