Olga Olga - 1 year ago 161
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.

Answer Source

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

object.attribute = object.attribute | variable

Read more here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download