Skip to content

Commit 072ec69

Browse files
bpo-43837: Reverse order of precedence table to show tightly binding operators first (GH-25469) (GH-25472)
1 parent 0121f67 commit 072ec69

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

Doc/reference/expressions.rst

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,8 +1807,8 @@ Operator precedence
18071807
.. index::
18081808
pair: operator; precedence
18091809

1810-
The following table summarizes the operator precedence in Python, from lowest
1811-
precedence (least binding) to highest precedence (most binding). Operators in
1810+
The following table summarizes the operator precedence in Python, from highest
1811+
precedence (most binding) to lowest precedence (least binding). Operators in
18121812
the same box have the same precedence. Unless the syntax is explicitly given,
18131813
operators are binary. Operators in the same box group left to right (except for
18141814
exponentiation, which groups from right to left).
@@ -1821,50 +1821,50 @@ precedence and have a left-to-right chaining feature as described in the
18211821
+-----------------------------------------------+-------------------------------------+
18221822
| Operator | Description |
18231823
+===============================================+=====================================+
1824-
| ``:=`` | Assignment expression |
1825-
+-----------------------------------------------+-------------------------------------+
1826-
| :keyword:`lambda` | Lambda expression |
1824+
| ``(expressions...)``, | Binding or parenthesized |
1825+
| | expression, |
1826+
| ``[expressions...]``, | list display, |
1827+
| ``{key: value...}``, | dictionary display, |
1828+
| ``{expressions...}`` | set display |
18271829
+-----------------------------------------------+-------------------------------------+
1828-
| :keyword:`if <if_expr>` -- :keyword:`!else` | Conditional expression |
1830+
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
1831+
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
18291832
+-----------------------------------------------+-------------------------------------+
1830-
| :keyword:`or` | Boolean OR |
1833+
| :keyword:`await` ``x`` | Await expression |
18311834
+-----------------------------------------------+-------------------------------------+
1832-
| :keyword:`and` | Boolean AND |
1835+
| ``**`` | Exponentiation [#]_ |
18331836
+-----------------------------------------------+-------------------------------------+
1834-
| :keyword:`not` ``x`` | Boolean NOT |
1837+
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
18351838
+-----------------------------------------------+-------------------------------------+
1836-
| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership |
1837-
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests |
1838-
| ``<=``, ``>``, ``>=``, ``!=``, ``==`` | |
1839+
| ``*``, ``@``, ``/``, ``//``, ``%`` | Multiplication, matrix |
1840+
| | multiplication, division, floor |
1841+
| | division, remainder [#]_ |
18391842
+-----------------------------------------------+-------------------------------------+
1840-
| ``|`` | Bitwise OR |
1843+
| ``+``, ``-`` | Addition and subtraction |
18411844
+-----------------------------------------------+-------------------------------------+
1842-
| ``^`` | Bitwise XOR |
1845+
| ``<<``, ``>>`` | Shifts |
18431846
+-----------------------------------------------+-------------------------------------+
18441847
| ``&`` | Bitwise AND |
18451848
+-----------------------------------------------+-------------------------------------+
1846-
| ``<<``, ``>>`` | Shifts |
1849+
| ``^`` | Bitwise XOR |
18471850
+-----------------------------------------------+-------------------------------------+
1848-
| ``+``, ``-`` | Addition and subtraction |
1851+
| ``|`` | Bitwise OR |
18491852
+-----------------------------------------------+-------------------------------------+
1850-
| ``*``, ``@``, ``/``, ``//``, ``%`` | Multiplication, matrix |
1851-
| | multiplication, division, floor |
1852-
| | division, remainder [#]_ |
1853+
| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership |
1854+
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests |
1855+
| ``<=``, ``>``, ``>=``, ``!=``, ``==`` | |
18531856
+-----------------------------------------------+-------------------------------------+
1854-
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
1857+
| :keyword:`not` ``x`` | Boolean NOT |
18551858
+-----------------------------------------------+-------------------------------------+
1856-
| ``**`` | Exponentiation [#]_ |
1859+
| :keyword:`and` | Boolean AND |
18571860
+-----------------------------------------------+-------------------------------------+
1858-
| :keyword:`await` ``x`` | Await expression |
1861+
| :keyword:`or` | Boolean OR |
18591862
+-----------------------------------------------+-------------------------------------+
1860-
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
1861-
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
1863+
| :keyword:`if <if_expr>` -- :keyword:`!else` | Conditional expression |
18621864
+-----------------------------------------------+-------------------------------------+
1863-
| ``(expressions...)``, | Binding or parenthesized |
1864-
| | expression, |
1865-
| ``[expressions...]``, | list display, |
1866-
| ``{key: value...}``, | dictionary display, |
1867-
| ``{expressions...}`` | set display |
1865+
| :keyword:`lambda` | Lambda expression |
1866+
+-----------------------------------------------+-------------------------------------+
1867+
| ``:=`` | Assignment expression |
18681868
+-----------------------------------------------+-------------------------------------+
18691869

18701870

0 commit comments

Comments
 (0)