Home Python Opeartor Precedence
Page
Cancel

Python Operator Precedence

The following order of operators from highest precedence (evaluated before others or most binding) to lowest precedence (evaluated after others or least binding) is respected in Python 3.10.

OperatorDescription
(expression ...), [expression ...],
{key: value ...}, {expression ...}
Binding or parenthesized expression, list display,
dictionary display, set display
x[index], x[index:index],
x(arguments...), x.attribute
Subscription, slicing, call, attribute reference
await xAwait expression
**Exponentiation
+x, -x, ~xPositive, negative, bitwise NOT
*, @, /, //, %Multiplication, matrix multiplication, division, floor,
division, remainder
+, -Addition and subtraction
<<, >>Shifts
&Bitwise AND
^Bitwise XOR
|Bitwise OR
in, not in, is, is not, <, <=, >, >=, !=, ==Comparisons, including membership tests and
identity tests
not xBoolean NOT
andBoolean AND
orBoolean OR
if elif elseConditional expression
lambdaLambda expression
:=Assignment expression

Table taken from 6.17 Operator Precedence