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
| Name | Type | Description |
|---|---|---|
| item | object | Item to select or search for. |
| items | object | Additional 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]))