Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e7cb1ce8
Commit
e7cb1ce8
authored
Feb 19, 2009
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#5310, #3558: fix operator precedence table.
parent
749e6d0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
28 deletions
+18
-28
Doc/reference/expressions.rst
Doc/reference/expressions.rst
+18
-28
No files found.
Doc/reference/expressions.rst
View file @
e7cb1ce8
...
...
@@ -816,14 +816,14 @@ Raising a negative number to a fractional power results in a :exc:`ValueError`.
.. _unary:
Unary arithmetic operations
===========================
Unary arithmetic
and bitwise
operations
===========================
============
.. index::
triple: unary; arithmetic; operation
triple: unary; bitwise; operation
All unary arithmetic
(and bitwise)
operations have the same priority:
All unary arithmetic
and bitwise
operations have the same priority:
.. productionlist::
u_expr: `power` | "-" `u_expr` | "+" `u_expr` | "~" `u_expr`
...
...
@@ -1276,12 +1276,9 @@ groups from right to left).
+-----------------------------------------------+-------------------------------------+
| :keyword:`not` *x* | Boolean NOT |
+-----------------------------------------------+-------------------------------------+
| :keyword:`in`, :keyword:`not` :keyword:`in` | Membership tests |
+-----------------------------------------------+-------------------------------------+
| :keyword:`is`, :keyword:`is not` | Identity tests |
+-----------------------------------------------+-------------------------------------+
| ``<``, ``<=``, ``>``, ``>=``, ``<>``, ``!=``, | Comparisons |
| ``==`` | |
| :keyword:`in`, :keyword:`not` :keyword:`in`, | Comparisons, including membership |
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests, |
| ``<=``, ``>``, ``>=``, ``<>``, ``!=``, ``==`` | |
+-----------------------------------------------+-------------------------------------+
| ``|`` | Bitwise OR |
+-----------------------------------------------+-------------------------------------+
...
...
@@ -1293,29 +1290,19 @@ groups from right to left).
+-----------------------------------------------+-------------------------------------+
| ``+``, ``-`` | Addition and subtraction |
+-----------------------------------------------+-------------------------------------+
| ``*``, ``/``, ``%`` | Multiplication, division, remainder |
+-----------------------------------------------+-------------------------------------+
| ``+x``, ``-x`` | Positive, negative |
+-----------------------------------------------+-------------------------------------+
| ``~x`` | Bitwise not |
+-----------------------------------------------+-------------------------------------+
| ``**`` | Exponentiation |
| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |
+-----------------------------------------------+-------------------------------------+
| ``
x[index]`` | Subscription
|
| ``
+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT
|
+-----------------------------------------------+-------------------------------------+
| ``
x[index:index]`` | Slicing
|
| ``
**`` | Exponentiation [#]_
|
+-----------------------------------------------+-------------------------------------+
| ``x(arguments...)`` | Call |
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
+-----------------------------------------------+-------------------------------------+
| ``x.attribute`` | Attribute reference |
+-----------------------------------------------+-------------------------------------+
| ``(expressions...)`` | Binding or tuple display |
+-----------------------------------------------+-------------------------------------+
| ``[expressions...]`` | List display |
+-----------------------------------------------+-------------------------------------+
| ``{key:datum...}`` | Dictionary display |
+-----------------------------------------------+-------------------------------------+
| ```expressions...``` | String conversion |
| ``(expressions...)``, | Binding or tuple display, |
| ``[expressions...]``, | list display, |
| ``{key:datum...}``, | dictionary display, |
| ```expressions...``` | string conversion |
+-----------------------------------------------+-------------------------------------+
.. rubric:: Footnotes
...
...
@@ -1358,3 +1345,6 @@ groups from right to left).
descriptors, you may notice seemingly unusual behaviour in certain uses of
the :keyword:`is` operator, like those involving comparisons between instance
methods, or constants. Check their documentation for more info.
.. [#] The power operator ``**`` binds less tightly than an arithmetic or
bitwise unary operator on its right, that is, ``2**-1`` is ``0.5``.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment