summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-02-23 10:41:11 (GMT)
committerGeorg Brandl <georg@python.org>2009-02-23 10:41:11 (GMT)
commitec7d3909bad5a9d5a116c18584f8aa89f8f0de42 (patch)
treea6ca9ea980c76db834727e795139bcfbb64afd5d /Doc/reference
parent9ac164c71cdcb12880fd392c77cc4dfa9b525158 (diff)
downloadcpython-ec7d3909bad5a9d5a116c18584f8aa89f8f0de42.zip
cpython-ec7d3909bad5a9d5a116c18584f8aa89f8f0de42.tar.gz
cpython-ec7d3909bad5a9d5a116c18584f8aa89f8f0de42.tar.bz2
Merged revisions 68582,68718,68720-68721,68724-68727,68859,68973,69288-69289,69293,69295,69297-69301,69409,69414,69570,69573,69576,69728-69730,69769,69776,69803-69805,69840,69896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68582 | georg.brandl | 2009-01-13 23:14:01 +0100 (Di, 13 Jan 2009) | 2 lines Use assertRaises. ........ r68718 | georg.brandl | 2009-01-18 11:42:35 +0100 (So, 18 Jan 2009) | 1 line #4976: union() and intersection() take multiple args, but talk about "the other". ........ r68720 | georg.brandl | 2009-01-18 11:45:22 +0100 (So, 18 Jan 2009) | 1 line #4974: fix redundant mention of lists and tuples. ........ r68721 | georg.brandl | 2009-01-18 11:48:16 +0100 (So, 18 Jan 2009) | 1 line #4914: trunc is in math. ........ r68724 | georg.brandl | 2009-01-18 14:24:10 +0100 (So, 18 Jan 2009) | 1 line #4979: correct result range for some random functions. ........ r68725 | georg.brandl | 2009-01-18 14:47:26 +0100 (So, 18 Jan 2009) | 1 line #4857: fix augmented assignment target spec. ........ r68726 | georg.brandl | 2009-01-18 15:41:52 +0100 (So, 18 Jan 2009) | 1 line #4923: clarify what was added. ........ r68727 | georg.brandl | 2009-01-18 19:25:30 +0100 (So, 18 Jan 2009) | 1 line #4986: augassigns are not expressions. ........ r68859 | georg.brandl | 2009-01-22 19:29:28 +0100 (Do, 22 Jan 2009) | 2 lines Clarify wording. ........ r68973 | georg.brandl | 2009-01-26 22:29:38 +0100 (Mo, 26 Jan 2009) | 2 lines Copy over docs on advanced role features from Sphinx docs. ........ r69288 | georg.brandl | 2009-02-05 11:30:57 +0100 (Do, 05 Feb 2009) | 1 line #5153: fix typo in example. ........ r69289 | georg.brandl | 2009-02-05 11:37:07 +0100 (Do, 05 Feb 2009) | 1 line #5144: document that PySys_SetArgv prepends the script directory (or the empty string) to sys.path. ........ r69293 | georg.brandl | 2009-02-05 11:59:28 +0100 (Do, 05 Feb 2009) | 1 line #5059: fix example. ........ r69295 | georg.brandl | 2009-02-05 12:23:47 +0100 (Do, 05 Feb 2009) | 1 line PyErr_PrintEx is also in 2.x... ........ r69297 | georg.brandl | 2009-02-05 12:32:18 +0100 (Do, 05 Feb 2009) | 1 line #5015: document PythonHome API functions. ........ r69298 | georg.brandl | 2009-02-05 12:33:21 +0100 (Do, 05 Feb 2009) | 1 line #4827: fix callback example. ........ r69299 | georg.brandl | 2009-02-05 12:35:28 +0100 (Do, 05 Feb 2009) | 1 line #4820: use correct module for ctypes.util. ........ r69300 | georg.brandl | 2009-02-05 12:38:23 +0100 (Do, 05 Feb 2009) | 1 line #4563: disable alpha and roman lists, fixes wrong formatting of contributor list. ........ r69301 | georg.brandl | 2009-02-05 12:40:35 +0100 (Do, 05 Feb 2009) | 1 line #5031: fix Thread.daemon property docs. ........ r69409 | georg.brandl | 2009-02-07 13:21:17 +0100 (Sa, 07 Feb 2009) | 1 line #5174: fix wrong file closing in example. ........ r69414 | georg.brandl | 2009-02-07 19:49:54 +0100 (Sa, 07 Feb 2009) | 1 line make "super only for new-style classes" a note. ........ r69570 | georg.brandl | 2009-02-13 11:40:14 +0100 (Fr, 13 Feb 2009) | 1 line #4894: document "newurl" parameter to redirect_request(). ........ r69573 | georg.brandl | 2009-02-13 11:44:17 +0100 (Fr, 13 Feb 2009) | 1 line #3734: document complex coercing behavior better. ........ r69576 | georg.brandl | 2009-02-13 11:56:50 +0100 (Fr, 13 Feb 2009) | 1 line #1661108: note that urlsafe encoded string can contain "=". ........ r69728 | georg.brandl | 2009-02-18 01:22:55 +0100 (Mi, 18 Feb 2009) | 2 lines #5297: fix example. ........ r69729 | georg.brandl | 2009-02-18 01:25:13 +0100 (Mi, 18 Feb 2009) | 2 lines #5296: sequence -> iterable. ........ r69730 | georg.brandl | 2009-02-18 01:31:36 +0100 (Mi, 18 Feb 2009) | 2 lines #5268: mention VMSError. ........ r69769 | georg.brandl | 2009-02-19 09:30:06 +0100 (Do, 19 Feb 2009) | 1 line #5310, #3558: fix operator precedence table. ........ r69776 | georg.brandl | 2009-02-19 17:34:51 +0100 (Do, 19 Feb 2009) | 2 lines #5317: update IronPython URL. ........ r69803 | georg.brandl | 2009-02-20 08:48:21 +0100 (Fr, 20 Feb 2009) | 1 line #5327: fix a broken link by joining it. ........ r69804 | georg.brandl | 2009-02-20 09:22:21 +0100 (Fr, 20 Feb 2009) | 1 line At least separate imports from other statements. ........ r69805 | georg.brandl | 2009-02-20 09:45:47 +0100 (Fr, 20 Feb 2009) | 2 lines Fix punctuation. ........ r69840 | georg.brandl | 2009-02-21 20:09:40 +0100 (Sa, 21 Feb 2009) | 1 line #5338, #5339: two types in the API manual. ........ r69896 | georg.brandl | 2009-02-23 11:24:23 +0100 (Mo, 23 Feb 2009) | 1 line #5348: format() converts all kinds of values. ........
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/datamodel.rst9
-rw-r--r--Doc/reference/expressions.rst46
-rw-r--r--Doc/reference/introduction.rst3
-rw-r--r--Doc/reference/simple_stmts.rst13
4 files changed, 31 insertions, 40 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index fae7352..d70f6ed 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2078,13 +2078,13 @@ left undefined.
object.__ixor__(self, other)
object.__ior__(self, other)
- These methods are called to implement the augmented arithmetic operations
+ These methods are called to implement the augmented arithmetic assignments
(``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``,
``&=``, ``^=``, ``|=``). These methods should attempt to do the operation
in-place (modifying *self*) and return the result (which could be, but does
not have to be, *self*). If a specific method is not defined, the augmented
- operation falls back to the normal methods. For instance, to evaluate the
- expression ``x += y``, where *x* is an instance of a class that has an
+ assignment falls back to the normal methods. For instance, to execute the
+ statement ``x += y``, where *x* is an instance of a class that has an
:meth:`__iadd__` method, ``x.__iadd__(y)`` is called. If *x* is an instance
of a class that does not define a :meth:`__iadd__` method, ``x.__add__(y)``
and ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``.
@@ -2244,7 +2244,8 @@ will not be supported.
In the current implementation, the built-in numeric types :class:`int`,
:class:`long` and :class:`float` do not use coercion; the type :class:`complex`
- however does use it. The difference can become apparent when subclassing these
+ however does use coercion for binary operators and rich comparisons, despite
+ the above rules. The difference can become apparent when subclassing these
types. Over time, the type :class:`complex` may be fixed to avoid coercion.
All these types implement a :meth:`__coerce__` method, for use by the built-in
:func:`coerce` function.
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 550644c..3664ee9 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -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``.
diff --git a/Doc/reference/introduction.rst b/Doc/reference/introduction.rst
index 8b2cceb..69bd41d 100644
--- a/Doc/reference/introduction.rst
+++ b/Doc/reference/introduction.rst
@@ -65,8 +65,7 @@ IronPython
An alternate Python for .NET. Unlike Python.NET, this is a complete Python
implementation that generates IL, and compiles Python code directly to .NET
assemblies. It was created by Jim Hugunin, the original creator of Jython. For
- more information, see `the IronPython website
- <http://workspaces.gotdotnet.com/ironpython>`_.
+ more information, see `the IronPython website <http://www.ironpython.com/>`_.
PyPy
An implementation of Python written in Python; even the bytecode interpreter is
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index d43ee8b..87ce403 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -118,8 +118,8 @@ Assignment of an object to a target list is recursively defined as follows.
* If the target list is a single target: The object is assigned to that target.
-* If the target list is a comma-separated list of targets: The object must be a
- sequence with the same number of items as there are targets in the target list,
+* If the target list is a comma-separated list of targets: The object must be an
+ iterable with the same number of items as there are targets in the target list,
and the items are assigned, from left to right, to the corresponding targets.
(This rule is relaxed as of Python 1.5; in earlier versions, the object had to
be a tuple. Since strings are sequences, an assignment like ``a, b = "xy"`` is
@@ -143,9 +143,9 @@ Assignment of an object to a single target is recursively defined as follows.
be deallocated and its destructor (if it has one) to be called.
* If the target is a target list enclosed in parentheses or in square brackets:
- The object must be a sequence with the same number of items as there are targets
- in the target list, and its items are assigned, from left to right, to the
- corresponding targets.
+ The object must be an iterable with the same number of items as there are
+ targets in the target list, and its items are assigned, from left to right,
+ to the corresponding targets.
.. index:: pair: attribute; assignment
@@ -228,7 +228,8 @@ Augmented assignment is the combination, in a single statement, of a binary
operation and an assignment statement:
.. productionlist::
- augmented_assignment_stmt: `target` `augop` (`expression_list` | `yield_expression`)
+ augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`)
+ augtarget: `identifier` | `attributeref` | `subscription` | `slicing`
augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
: | ">>=" | "<<=" | "&=" | "^=" | "|="