| Python operator precedence |
| within the same precedence operators work left to right Except for exponents, comparisons, and assignments |
| | Operator Description |
| {} | dictionary, set, and their comprehensions |
| [] | list, list comprehensions |
| () | tuple, expression, generator expression |
| x.attr | attribute reference |
| x() | call |
| x[i:j:k] | slice |
| x[i] | indexing |
| x ** y | exponent |
| ~x | bitwise NOT |
| -x, +x | negation |
| x/y, x//y | division |
| x % y | remainder |
| x * y | multiplication, repeatition |
| x – y | subtraction, set difference |
| x + y | addition, concatenation |
x>>y, x< | bitwise right and left shift | |
| x & y | bitwise AND, set intersection |
| X ^ y | bitwise XOR, set symmetric difference |
| x | y | bitwise OR, set union |
| x==y, x !=y | value equality |
| >, <, >=, <= | value comparison, subset, superset |
| =, +=, -=, *=, /=, %=, **=, //= | “assignment” (set reference) |
| x is y, x is not y | object identity |
| x In y , x not in y | membership |
| not x | logical negation |
| x and y | logical and |
| x or y | logical or |
| x if y else z | ternary operator |
| lambda args : expression | anonymous in-line function |
| yield y | generator function send protocol |