Python Language Reference Manualby Guido van Rossum and Fred L. Drake, Jr. Paperback (6"x9"), 120 pages ISBN 0954161785 RRP £12.95 ($19.95) Sales of this book support the Python Software Foundation! Get a printed copy>>> |

## 5.8 Binary bit-wise operations

Each of the three bitwise operations has a different priority level:

`and_expr`

`shift_expr`

|`and_expr`

"&"`shift_expr`

`xor_expr`

`and_expr`

|`xor_expr`

"^"`and_expr`

`or_expr`

`xor_expr`

|`or_expr`

"|"`xor_expr`

The `&`

operator yields the bitwise AND of its arguments, which
must be plain or long integers. The arguments are converted to a
common type.

The `^`

operator yields the bitwise XOR (exclusive OR) of its
arguments, which must be plain or long integers. The arguments are
converted to a common type.

The `|`

operator yields the bitwise (inclusive) OR of its
arguments, which must be plain or long integers. The arguments are
converted to a common type.

ISBN 0954161785 | Python Language Reference Manual | See the print edition |