mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
bpo-43837: Reverse order of precedence table to show tightly binding operators first (GH-25469)
This commit is contained in:
parent
64d975202f
commit
68ba0c67ca
1 changed files with 41 additions and 41 deletions
|
|
@ -1819,8 +1819,8 @@ Operator precedence
|
||||||
.. index::
|
.. index::
|
||||||
pair: operator; precedence
|
pair: operator; precedence
|
||||||
|
|
||||||
The following table summarizes the operator precedence in Python, from lowest
|
The following table summarizes the operator precedence in Python, from highest
|
||||||
precedence (least binding) to highest precedence (most binding). Operators in
|
precedence (most binding) to lowest precedence (least binding). Operators in
|
||||||
the same box have the same precedence. Unless the syntax is explicitly given,
|
the same box have the same precedence. Unless the syntax is explicitly given,
|
||||||
operators are binary. Operators in the same box group left to right (except for
|
operators are binary. Operators in the same box group left to right (except for
|
||||||
exponentiation, which groups from right to left).
|
exponentiation, which groups from right to left).
|
||||||
|
|
@ -1833,51 +1833,51 @@ precedence and have a left-to-right chaining feature as described in the
|
||||||
+-----------------------------------------------+-------------------------------------+
|
+-----------------------------------------------+-------------------------------------+
|
||||||
| Operator | Description |
|
| Operator | Description |
|
||||||
+===============================================+=====================================+
|
+===============================================+=====================================+
|
||||||
| ``:=`` | Assignment expression |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`lambda` | Lambda expression |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`if <if_expr>` -- :keyword:`!else` | Conditional expression |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`or` | Boolean OR |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`and` | Boolean AND |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`not` ``x`` | Boolean NOT |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership |
|
|
||||||
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests |
|
|
||||||
| ``<=``, ``>``, ``>=``, ``!=``, ``==`` | |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``|`` | Bitwise OR |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``^`` | Bitwise XOR |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``&`` | Bitwise AND |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``<<``, ``>>`` | Shifts |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``+``, ``-`` | Addition and subtraction |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``*``, ``@``, ``/``, ``//``, ``%`` | Multiplication, matrix |
|
|
||||||
| | multiplication, division, floor |
|
|
||||||
| | division, remainder [#]_ |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``**`` | Exponentiation [#]_ |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| :keyword:`await` ``x`` | Await expression |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
|
|
||||||
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
|
|
||||||
+-----------------------------------------------+-------------------------------------+
|
|
||||||
| ``(expressions...)``, | Binding or parenthesized |
|
| ``(expressions...)``, | Binding or parenthesized |
|
||||||
| | expression, |
|
| | expression, |
|
||||||
| ``[expressions...]``, | list display, |
|
| ``[expressions...]``, | list display, |
|
||||||
| ``{key: value...}``, | dictionary display, |
|
| ``{key: value...}``, | dictionary display, |
|
||||||
| ``{expressions...}`` | set display |
|
| ``{expressions...}`` | set display |
|
||||||
+-----------------------------------------------+-------------------------------------+
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
|
||||||
|
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`await` ``x`` | Await expression |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``**`` | Exponentiation [#]_ |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``*``, ``@``, ``/``, ``//``, ``%`` | Multiplication, matrix |
|
||||||
|
| | multiplication, division, floor |
|
||||||
|
| | division, remainder [#]_ |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``+``, ``-`` | Addition and subtraction |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``<<``, ``>>`` | Shifts |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``&`` | Bitwise AND |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``^`` | Bitwise XOR |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``|`` | Bitwise OR |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership |
|
||||||
|
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests |
|
||||||
|
| ``<=``, ``>``, ``>=``, ``!=``, ``==`` | |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`not` ``x`` | Boolean NOT |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`and` | Boolean AND |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`or` | Boolean OR |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`if <if_expr>` -- :keyword:`!else` | Conditional expression |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| :keyword:`lambda` | Lambda expression |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
| ``:=`` | Assignment expression |
|
||||||
|
+-----------------------------------------------+-------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue