Python Glossary Русский

all Python 3operatorfunction

operator.iand

in-place

In-place bitwise AND: a &= b; for sets, an in-place intersection.

Syntax

operator.iand(a, b)

For a set it mutates in place, leaving the intersection: after iand(s, {2, 3}) only the shared items remain in s, and every reference to s sees it. For ints assign the result. Like and_, it is a bitwise operation with no short-circuit, not logical and.

Examples

import operator
print(operator.iand(5, 3))   # → 1
print(operator.iand(5, 3) == (5 & 3))   # → True
x = 5
print(operator.iand(x, 3), x)   # → 1 5
print(sorted(operator.iand({1, 2, 3}, {2, 3, 4})))   # → [2, 3]
print(list(map(operator.iand, [6, 12], [3, 10])))   # → [2, 8]

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy