On this page
operator.getitem
Prev: operator.ge | Up: operator | Next: operator.gt
Rel: operator.abs, operator.add, operator.and_, operator.attrgetter
Ref: docs.python.org — operator.getitem
Tags: #public #python3 #stdlib #operator
Import
import operator
from operator import getitem
Signature & Overview
operator.getitem(a, b, /)
Same as a[b].
Usage
import operator
assert operator.getitem({"k": 42}, "k") == 42
Gotchas
- For repeated lookups on fixed keys/indices, prefer
operator.itemgetter(k).
REPL Inspect
from operator import getitem
help(getitem)
Linked from
Related notes
- tuts/python3/stdlib_module/operator/ge Linked here; links to this page; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/gt 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