On this page
operator.contains
Prev: operator.concat | Up: operator | Next: operator.countOf
Rel: operator.abs, operator.add, operator.and_, operator.attrgetter
Ref: docs.python.org — operator.contains
Tags: #public #python3 #stdlib #operator
Import
import operator
from operator import contains
Signature & Overview
operator.contains(a, b, /)
Same as b in a (note reversed operands).
Usage
import operator
assert operator.contains([1, 2, 3], 2) is True
Gotchas
- Argument order is
(container, item)—opposite of English"item in container"!
REPL Inspect
from operator import contains
help(contains)
Linked from
Related notes
- tuts/python3/stdlib_module/operator/concat Linked here; links to this page; shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/countOf 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/delitem shared tags: #operator, #stdlib
- tuts/python3/stdlib_module/operator/eq shared tags: #operator, #stdlib