Skip to content

Commit 68ba0c6

Browse files
authored
bpo-43837: Reverse order of precedence table to show tightly binding operators first (GH-25469)
1 parent 64d9752 commit 68ba0c6

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
@@ -1819,8 +1819,8 @@ Operator precedence
18191819
.. index::
18201820
pair: operator; precedence
18211821

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
18241824
the same box have the same precedence. Unless the syntax is explicitly given,
18251825
operators are binary. Operators in the same box group left to right (except for
18261826
exponentiation, which groups from right to left).
@@ -1833,50 +1833,50 @@ precedence and have a left-to-right chaining feature as described in the
18331833
+-----------------------------------------------+-------------------------------------+
18341834
| Operator | Description |
18351835
+===============================================+=====================================+
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 |
18391841
+-----------------------------------------------+-------------------------------------+
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 |
18411844
+-----------------------------------------------+-------------------------------------+
1842-
| :keyword:`or` | Boolean OR |
1845+
| :keyword:`await` ``x`` | Await expression |
18431846
+-----------------------------------------------+-------------------------------------+
1844-
| :keyword:`and` | Boolean AND |
1847+
| ``**`` | Exponentiation [#]_ |
18451848
+-----------------------------------------------+-------------------------------------+
1846-
| :keyword:`not` ``x`` | Boolean NOT |
1849+
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
18471850
+-----------------------------------------------+-------------------------------------+
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 [#]_ |
18511854
+-----------------------------------------------+-------------------------------------+
1852-
| ``|`` | Bitwise OR |
1855+
| ``+``, ``-`` | Addition and subtraction |
18531856
+-----------------------------------------------+-------------------------------------+
1854-
| ``^`` | Bitwise XOR |
1857+
| ``<<``, ``>>`` | Shifts |
18551858
+-----------------------------------------------+-------------------------------------+
18561859
| ``&`` | Bitwise AND |
18571860
+-----------------------------------------------+-------------------------------------+
1858-
| ``<<``, ``>>`` | Shifts |
1861+
| ``^`` | Bitwise XOR |
18591862
+-----------------------------------------------+-------------------------------------+
1860-
| ``+``, ``-`` | Addition and subtraction |
1863+
| ``|`` | Bitwise OR |
18611864
+-----------------------------------------------+-------------------------------------+
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+
| ``<=``, ``>``, ``>=``, ``!=``, ``==`` | |
18651868
+-----------------------------------------------+-------------------------------------+
1866-
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
1869+
| :keyword:`not` ``x`` | Boolean NOT |
18671870
+-----------------------------------------------+-------------------------------------+
1868-
| ``**`` | Exponentiation [#]_ |
1871+
| :keyword:`and` | Boolean AND |
18691872
+-----------------------------------------------+-------------------------------------+
1870-
| :keyword:`await` ``x`` | Await expression |
1873+
| :keyword:`or` | Boolean OR |
18711874
+-----------------------------------------------+-------------------------------------+
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 |
18741876
+-----------------------------------------------+-------------------------------------+
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 |
18801880
+-----------------------------------------------+-------------------------------------+
18811881

18821882

0 commit comments

Comments
 (0)