From Python documentation on operator precedence (Section 5.15)
Highest precedence at top, lowest at bottom.
Operators in the same box evaluate left to right.
Operator | Description |
---|---|
() | Parentheses (grouping) |
f(args...) | Function call |
x[index:index] | Slicing |
x[index] | Subscription |
x.attribute | Attribute reference |
** | Exponentiation |
~x | Bitwise not |
+x, -x | Positive, negative |
*, /, % | Multiplication, division, remainder |
+, - | Addition, subtraction |
<<, >> | Bitwise shifts |
& | Bitwise AND |
^ | Bitwise XOR |
| | Bitwise OR |
in, not in, is, is not, <, <=, >, >=, <>, !=, == |
Comparisons, membership, identity |
not x | Boolean NOT |
and | Boolean AND |
or | Boolean OR |
lambda | Lambda expression |