This is a compound statement when you say: x |= y
is equivalent to x = x | y
x = x | y
Operator |
means bitwise or
, and it works with integers at the bit level, here is an example:
a = 3
Another example:
a = 2
Thus, each bit will be set as a result if the same bit is set in either of the two sources, and is equal to zero if both sources have zero in this bit.
Pipe is also used on sets to get a mix:
a = {1,2,3} b = {2,3,4} c = {4,5,6} print(a | b | c)
Bilal source share