Olga Olga - 3 months ago 32x
Python Question

Vertical bar in Python bitwise assignment operator

There is a code and in class' method there is a line:

object.attribute |= variable

I can't understand what it means. I didn't find (|=) in the list of basic Python operators.


That is a bitwise or with assignment. It is equivalent to

object.attribute = object.attribute | variable

Read more here.