I just came across an assignment like this in python. I checked everywhere to see what this was but couldn't find it. What does this mean in python?
total_mask |= is_NA
The operator in the middle is confusing me.
Thanks
It's just an operator of logical OR.
If total_mask is
0011101010101001110
and is_NA is
0000000000000100000
then total_mask will become
0011101010101101110
in this case it's just like addition.
EDIT: of course the numbers are here written in binary.
In Python you can convert a number to a binary string using the bin function, for example
>>> bin(99)
'0b1100011'
It is the same as
total_mask = total_mask|is_NA
set.__ior__) will preserve the identity of the set, whereas the method you have shown will create a new set. this can have side effects for other references to the same set.
A ?= Bis the same asA = A ? B, for most any operator you care to replace the question mark with.