@@ -1819,8 +1819,8 @@ Operator precedence
1819
1819
.. index ::
1820
1820
pair: operator; precedence
1821
1821
1822
- The following table summarizes the operator precedence in Python, from lowest
1823
- precedence (least binding) to highest precedence (most binding). Operators in
1822
+ The following table summarizes the operator precedence in Python, from highest
1823
+ precedence (most binding) to lowest precedence (least binding). Operators in
1824
1824
the same box have the same precedence. Unless the syntax is explicitly given,
1825
1825
operators are binary. Operators in the same box group left to right (except for
1826
1826
exponentiation, which groups from right to left).
@@ -1833,50 +1833,50 @@ precedence and have a left-to-right chaining feature as described in the
1833
1833
+-----------------------------------------------+-------------------------------------+
1834
1834
| Operator | Description |
1835
1835
+===============================================+=====================================+
1836
- | ``:= `` | Assignment expression |
1837
- +-----------------------------------------------+-------------------------------------+
1838
- | :keyword: `lambda ` | Lambda expression |
1836
+ | ``(expressions...) ``, | Binding or parenthesized |
1837
+ | | expression, |
1838
+ | ``[expressions...] ``, | list display, |
1839
+ | ``{key: value...} ``, | dictionary display, |
1840
+ | ``{expressions...} `` | set display |
1839
1841
+-----------------------------------------------+-------------------------------------+
1840
- | :keyword: `if <if_expr> ` -- :keyword: `!else ` | Conditional expression |
1842
+ | ``x[index] ``, ``x[index:index] ``, | Subscription, slicing, |
1843
+ | ``x(arguments...) ``, ``x.attribute `` | call, attribute reference |
1841
1844
+-----------------------------------------------+-------------------------------------+
1842
- | :keyword: `or ` | Boolean OR |
1845
+ | :keyword: `await ` `` x `` | Await expression |
1843
1846
+-----------------------------------------------+-------------------------------------+
1844
- | :keyword: ` and ` | Boolean AND |
1847
+ | `` ** `` | Exponentiation [ # ]_ |
1845
1848
+-----------------------------------------------+-------------------------------------+
1846
- | :keyword: ` not ` ``x `` | Boolean NOT |
1849
+ | `` +x ``, ``- x ``, `` ~x `` | Positive, negative, bitwise NOT |
1847
1850
+-----------------------------------------------+-------------------------------------+
1848
- | :keyword: ` in `, :keyword: ` not in `, | Comparisons, including membership |
1849
- | :keyword: ` is `, :keyword: ` is not `, `` < ``, | tests and identity tests |
1850
- | `` <= ``, `` > ``, `` >= ``, `` != ``, `` == `` | |
1851
+ | `` * ``, `` @ ``, `` / ``, `` // ``, `` % `` | Multiplication, matrix |
1852
+ | | multiplication, division, floor |
1853
+ | | division, remainder [ # ]_ |
1851
1854
+-----------------------------------------------+-------------------------------------+
1852
- | ``| `` | Bitwise OR |
1855
+ | ``+ ``, `` - `` | Addition and subtraction |
1853
1856
+-----------------------------------------------+-------------------------------------+
1854
- | ``^ `` | Bitwise XOR |
1857
+ | ``<< ``, `` >> `` | Shifts |
1855
1858
+-----------------------------------------------+-------------------------------------+
1856
1859
| ``& `` | Bitwise AND |
1857
1860
+-----------------------------------------------+-------------------------------------+
1858
- | ``<< ``, `` >> `` | Shifts |
1861
+ | ``^ `` | Bitwise XOR |
1859
1862
+-----------------------------------------------+-------------------------------------+
1860
- | ``+ ``, `` - `` | Addition and subtraction |
1863
+ | ``| `` | Bitwise OR |
1861
1864
+-----------------------------------------------+-------------------------------------+
1862
- | `` * ``, `` @ ``, `` / ``, `` // ``, `` % `` | Multiplication, matrix |
1863
- | | multiplication, division, floor |
1864
- | | division, remainder [ # ]_ |
1865
+ | :keyword: ` in `, :keyword: ` not in `, | Comparisons, including membership |
1866
+ | :keyword: ` is `, :keyword: ` is not `, `` < ``, | tests and identity tests |
1867
+ | `` <= ``, `` > ``, `` >= ``, `` != ``, `` == `` | |
1865
1868
+-----------------------------------------------+-------------------------------------+
1866
- | `` +x ``, ``- x ``, `` ~x `` | Positive, negative, bitwise NOT |
1869
+ | :keyword: ` not ` ``x `` | Boolean NOT |
1867
1870
+-----------------------------------------------+-------------------------------------+
1868
- | `` ** `` | Exponentiation [ # ]_ |
1871
+ | :keyword: ` and ` | Boolean AND |
1869
1872
+-----------------------------------------------+-------------------------------------+
1870
- | :keyword: `await ` `` x `` | Await expression |
1873
+ | :keyword: `or ` | Boolean OR |
1871
1874
+-----------------------------------------------+-------------------------------------+
1872
- | ``x[index] ``, ``x[index:index] ``, | Subscription, slicing, |
1873
- | ``x(arguments...) ``, ``x.attribute `` | call, attribute reference |
1875
+ | :keyword: `if <if_expr> ` -- :keyword: `!else ` | Conditional expression |
1874
1876
+-----------------------------------------------+-------------------------------------+
1875
- | ``(expressions...) ``, | Binding or parenthesized |
1876
- | | expression, |
1877
- | ``[expressions...] ``, | list display, |
1878
- | ``{key: value...} ``, | dictionary display, |
1879
- | ``{expressions...} `` | set display |
1877
+ | :keyword: `lambda ` | Lambda expression |
1878
+ +-----------------------------------------------+-------------------------------------+
1879
+ | ``:= `` | Assignment expression |
1880
1880
+-----------------------------------------------+-------------------------------------+
1881
1881
1882
1882
0 commit comments