mirror of https://github.com/python/cpython
Merged revisions 69769,69776 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69769 | georg.brandl | 2009-02-19 02:30:06 -0600 (Thu, 19 Feb 2009) | 1 line #5310, #3558: fix operator precedence table. ........ r69776 | georg.brandl | 2009-02-19 10:34:51 -0600 (Thu, 19 Feb 2009) | 2 lines #5317: update IronPython URL. ........
This commit is contained in:
parent
93d83da8e2
commit
ba01dd93d2
|
@ -785,14 +785,14 @@ number. (In earlier versions it raised a :exc:`ValueError`.)
|
||||||
|
|
||||||
.. _unary:
|
.. _unary:
|
||||||
|
|
||||||
Unary arithmetic operations
|
Unary arithmetic and bitwise operations
|
||||||
===========================
|
=======================================
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
triple: unary; arithmetic; operation
|
triple: unary; arithmetic; operation
|
||||||
triple: unary; bitwise; 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::
|
.. productionlist::
|
||||||
u_expr: `power` | "-" `u_expr` | "+" `u_expr` | "~" `u_expr`
|
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
|
||||||
left to right --- see section :ref:`comparisons` --- and exponentiation, which
|
left to right --- see section :ref:`comparisons` --- and exponentiation, which
|
||||||
groups from right to left).
|
groups from right to left).
|
||||||
|
|
||||||
+----------------------------------------------+-------------------------------------+
|
|
||||||
| Operator | Description |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+==============================================+=====================================+
|
| Operator | Description |
|
||||||
| :keyword:`lambda` | Lambda expression |
|
+===============================================+=====================================+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| :keyword:`lambda` | Lambda expression |
|
||||||
| :keyword:`or` | Boolean OR |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| :keyword:`or` | Boolean OR |
|
||||||
| :keyword:`and` | Boolean AND |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| :keyword:`and` | Boolean AND |
|
||||||
| :keyword:`not` *x* | Boolean NOT |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| :keyword:`not` *x* | Boolean NOT |
|
||||||
| :keyword:`in`, :keyword:`not` :keyword:`in` | Membership tests |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| :keyword:`in`, :keyword:`not` :keyword:`in`, | Comparisons, including membership |
|
||||||
| :keyword:`is`, :keyword:`is not` | Identity tests |
|
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests, |
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``<=``, ``>``, ``>=``, ``<>``, ``!=``, ``==`` | |
|
||||||
| ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``==`` | Comparisons |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``|`` | Bitwise OR |
|
||||||
| ``|`` | Bitwise OR |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``^`` | Bitwise XOR |
|
||||||
| ``^`` | Bitwise XOR |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``&`` | Bitwise AND |
|
||||||
| ``&`` | Bitwise AND |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``<<``, ``>>`` | Shifts |
|
||||||
| ``<<``, ``>>`` | Shifts |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``+``, ``-`` | Addition and subtraction |
|
||||||
| ``+``, ``-`` | Addition and subtraction |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |
|
||||||
| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
|
||||||
| ``+x``, ``-x`` | Positive, negative |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``**`` | Exponentiation [#]_ |
|
||||||
| ``~x`` | Bitwise not |
|
+-----------------------------------------------+-------------------------------------+
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
|
||||||
| ``**`` | Exponentiation |
|
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
|
||||||
+----------------------------------------------+-------------------------------------+
|
+-----------------------------------------------+-------------------------------------+
|
||||||
| ``x[index]`` | Subscription |
|
| ``(expressions...)``, | Binding or tuple display, |
|
||||||
+----------------------------------------------+-------------------------------------+
|
| ``[expressions...]``, | list display, |
|
||||||
| ``x[index:index]`` | Slicing |
|
| ``{key:datum...}``, | dictionary display, |
|
||||||
+----------------------------------------------+-------------------------------------+
|
+-----------------------------------------------+-------------------------------------+
|
||||||
| ``x(arguments...)`` | Call |
|
|
||||||
+----------------------------------------------+-------------------------------------+
|
|
||||||
| ``x.attribute`` | Attribute reference |
|
|
||||||
+----------------------------------------------+-------------------------------------+
|
|
||||||
| ``(expressions...)`` | Binding, tuple display, generator |
|
|
||||||
| | expressions |
|
|
||||||
+----------------------------------------------+-------------------------------------+
|
|
||||||
| ``[expressions...]`` | List display |
|
|
||||||
+----------------------------------------------+-------------------------------------+
|
|
||||||
| ``{expressions...}`` | Dictionary or set display |
|
|
||||||
+----------------------------------------------+-------------------------------------+
|
|
||||||
|
|
||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
|
@ -1327,3 +1317,6 @@ groups from right to left).
|
||||||
descriptors, you may notice seemingly unusual behaviour in certain uses of
|
descriptors, you may notice seemingly unusual behaviour in certain uses of
|
||||||
the :keyword:`is` operator, like those involving comparisons between instance
|
the :keyword:`is` operator, like those involving comparisons between instance
|
||||||
methods, or constants. Check their documentation for more info.
|
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``.
|
||||||
|
|
|
@ -66,8 +66,7 @@ IronPython
|
||||||
An alternate Python for .NET. Unlike Python.NET, this is a complete Python
|
An alternate Python for .NET. Unlike Python.NET, this is a complete Python
|
||||||
implementation that generates IL, and compiles Python code directly to .NET
|
implementation that generates IL, and compiles Python code directly to .NET
|
||||||
assemblies. It was created by Jim Hugunin, the original creator of Jython. For
|
assemblies. It was created by Jim Hugunin, the original creator of Jython. For
|
||||||
more information, see `the IronPython website
|
more information, see `the IronPython website <http://www.ironpython.com/>`_.
|
||||||
<http://workspaces.gotdotnet.com/ironpython>`_.
|
|
||||||
|
|
||||||
PyPy
|
PyPy
|
||||||
An implementation of Python written in Python; even the bytecode interpreter is
|
An implementation of Python written in Python; even the bytecode interpreter is
|
||||||
|
|
Loading…
Reference in New Issue