@@ -785,14 +785,14 @@ number. (In earlier versions it raised a :exc:`ValueError`.)
785785
786786.. _unary :
787787
788- Unary arithmetic operations
789- ===========================
788+ Unary arithmetic and bitwise operations
789+ =======================================
790790
791791.. index ::
792792 triple: unary; arithmetic; operation
793793 triple: unary; bitwise; operation
794794
795- All unary arithmetic ( and bitwise) operations have the same priority:
795+ All unary arithmetic and bitwise operations have the same priority:
796796
797797.. productionlist ::
798798 u_expr: `power ` | "-" `u_expr ` | "+" `u_expr ` | "~" `u_expr `
@@ -1240,56 +1240,46 @@ comparisons, including tests, which all have the same precedence and chain from
12401240left to right --- see section :ref: `comparisons ` --- and exponentiation, which
12411241groups from right to left).
12421242
1243- +----------------------------------------------+-------------------------------------+
1244- | Operator | Description |
1245- +==============================================+=====================================+
1246- | :keyword: `lambda ` | Lambda expression |
1247- +----------------------------------------------+-------------------------------------+
1248- | :keyword: `or ` | Boolean OR |
1249- +----------------------------------------------+-------------------------------------+
1250- | :keyword: `and ` | Boolean AND |
1251- +----------------------------------------------+-------------------------------------+
1252- | :keyword: `not ` *x * | Boolean NOT |
1253- +----------------------------------------------+-------------------------------------+
1254- | :keyword: `in `, :keyword: `not ` :keyword: `in ` | Membership tests |
1255- +----------------------------------------------+-------------------------------------+
1256- | :keyword: `is `, :keyword: `is not ` | Identity tests |
1257- +----------------------------------------------+-------------------------------------+
1258- | ``< ``, ``<= ``, ``> ``, ``>= ``, ``!= ``, ``== `` | Comparisons |
1259- +----------------------------------------------+-------------------------------------+
1260- | ``| `` | Bitwise OR |
1261- +----------------------------------------------+-------------------------------------+
1262- | ``^ `` | Bitwise XOR |
1263- +----------------------------------------------+-------------------------------------+
1264- | ``& `` | Bitwise AND |
1265- +----------------------------------------------+-------------------------------------+
1266- | ``<< ``, ``>> `` | Shifts |
1267- +----------------------------------------------+-------------------------------------+
1268- | ``+ ``, ``- `` | Addition and subtraction |
1269- +----------------------------------------------+-------------------------------------+
1270- | ``* ``, ``/ ``, ``// ``, ``% `` | Multiplication, division, remainder |
1271- +----------------------------------------------+-------------------------------------+
1272- | ``+x ``, ``-x `` | Positive, negative |
1273- +----------------------------------------------+-------------------------------------+
1274- | ``~x `` | Bitwise not |
1275- +----------------------------------------------+-------------------------------------+
1276- | ``** `` | Exponentiation |
1277- +----------------------------------------------+-------------------------------------+
1278- | ``x[index] `` | Subscription |
1279- +----------------------------------------------+-------------------------------------+
1280- | ``x[index:index] `` | Slicing |
1281- +----------------------------------------------+-------------------------------------+
1282- | ``x(arguments...) `` | Call |
1283- +----------------------------------------------+-------------------------------------+
1284- | ``x.attribute `` | Attribute reference |
1285- +----------------------------------------------+-------------------------------------+
1286- | ``(expressions...) `` | Binding, tuple display, generator |
1287- | | expressions |
1288- +----------------------------------------------+-------------------------------------+
1289- | ``[expressions...] `` | List display |
1290- +----------------------------------------------+-------------------------------------+
1291- | ``{expressions...} `` | Dictionary or set display |
1292- +----------------------------------------------+-------------------------------------+
1243+
1244+ +-----------------------------------------------+-------------------------------------+
1245+ | Operator | Description |
1246+ +===============================================+=====================================+
1247+ | :keyword: `lambda ` | Lambda expression |
1248+ +-----------------------------------------------+-------------------------------------+
1249+ | :keyword: `or ` | Boolean OR |
1250+ +-----------------------------------------------+-------------------------------------+
1251+ | :keyword: `and ` | Boolean AND |
1252+ +-----------------------------------------------+-------------------------------------+
1253+ | :keyword: `not ` *x * | Boolean NOT |
1254+ +-----------------------------------------------+-------------------------------------+
1255+ | :keyword: `in `, :keyword: `not ` :keyword: `in `, | Comparisons, including membership |
1256+ | :keyword: `is `, :keyword: `is not `, ``< ``, | tests and identity tests, |
1257+ | ``<= ``, ``> ``, ``>= ``, ``<> ``, ``!= ``, ``== `` | |
1258+ +-----------------------------------------------+-------------------------------------+
1259+ | ``| `` | Bitwise OR |
1260+ +-----------------------------------------------+-------------------------------------+
1261+ | ``^ `` | Bitwise XOR |
1262+ +-----------------------------------------------+-------------------------------------+
1263+ | ``& `` | Bitwise AND |
1264+ +-----------------------------------------------+-------------------------------------+
1265+ | ``<< ``, ``>> `` | Shifts |
1266+ +-----------------------------------------------+-------------------------------------+
1267+ | ``+ ``, ``- `` | Addition and subtraction |
1268+ +-----------------------------------------------+-------------------------------------+
1269+ | ``* ``, ``/ ``, ``// ``, ``% `` | Multiplication, division, remainder |
1270+ +-----------------------------------------------+-------------------------------------+
1271+ | ``+x ``, ``-x ``, ``~x `` | Positive, negative, bitwise NOT |
1272+ +-----------------------------------------------+-------------------------------------+
1273+ | ``** `` | Exponentiation [# ]_ |
1274+ +-----------------------------------------------+-------------------------------------+
1275+ | ``x[index] ``, ``x[index:index] ``, | Subscription, slicing, |
1276+ | ``x(arguments...) ``, ``x.attribute `` | call, attribute reference |
1277+ +-----------------------------------------------+-------------------------------------+
1278+ | ``(expressions...) ``, | Binding or tuple display, |
1279+ | ``[expressions...] ``, | list display, |
1280+ | ``{key:datum...} ``, | dictionary display, |
1281+ +-----------------------------------------------+-------------------------------------+
1282+
12931283
12941284.. rubric :: Footnotes
12951285
@@ -1327,3 +1317,6 @@ groups from right to left).
13271317 descriptors, you may notice seemingly unusual behaviour in certain uses of
13281318 the :keyword: `is ` operator, like those involving comparisons between instance
13291319 methods, or constants. Check their documentation for more info.
1320+
1321+ .. [# ] The power operator ``** `` binds less tightly than an arithmetic or
1322+ bitwise unary operator on its right, that is, ``2**-1 `` is ``0.5 ``.
0 commit comments