Python Operator Precedence
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 |