CKTIS / Python
Operator |=
Sets the indicated bits in the stored integer while preserving the bits already present.
Version: Python 3.14; repository image, production runtime not attested
Syntax
target |= valueSets the indicated bits in the stored integer while preserving the bits already present.
Enable selected flags while retaining the previously enabled ones. With integer inputs this stores a new integer and can increase its bit length.
With dictionaries the update merges bindings into the existing mapping. A duplicate key takes its incoming value, and other references to that dictionary observe the mutation.
Bits already set remain set, making repeated application of a mask idempotent.
Syntax
target |= value
__ior__, __or__, __ror__ · TypeError
Worked example
mask = 0b1100; mask |= 0b0110
mask → 0b1110
Examples
value = 0b1100
value |= 0b1010
print(value)
print(bin(value))
Result
14 0b1110
Bits already set remain set, making repeated application of a mask idempotent.