summaryrefslogtreecommitdiffstats
path: root/Doc
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
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')
-rw-r--r--Doc/c-api/exceptions.rst11
-rw-r--r--Doc/c-api/init.rst32
-rw-r--r--Doc/c-api/intro.rst2
-rw-r--r--Doc/c-api/veryhigh.rst2
-rw-r--r--Doc/documenting/markup.rst23
-rw-r--r--Doc/howto/webservers.rst3
-rw-r--r--Doc/library/base64.rst3
-rw-r--r--Doc/library/cgi.rst15
-rw-r--r--Doc/library/cgitb.rst5
-rw-r--r--Doc/library/cookielib.rst2
-rw-r--r--Doc/library/ctypes.rst1
-rw-r--r--Doc/library/datetime.rst11
-rw-r--r--Doc/library/exceptions.rst5
-rw-r--r--Doc/library/functions.rst26
-rw-r--r--Doc/library/optparse.rst4
-rw-r--r--Doc/library/random.rst19
-rw-r--r--Doc/library/socketserver.rst2
-rw-r--r--Doc/library/stdtypes.rst12
-rw-r--r--Doc/library/threading.rst11
-rw-r--r--Doc/library/urllib2.rst11
-rw-r--r--Doc/library/xml.etree.elementtree.rst2
-rw-r--r--Doc/library/xmlrpclib.rst10
-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
-rwxr-xr-xDoc/tools/rstlint.py3
-rw-r--r--Doc/tools/sphinxext/pyspecific.py8
-rw-r--r--Doc/whatsnew/2.5.rst4
29 files changed, 188 insertions, 110 deletions
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index 536b123..d3f9135 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -41,12 +41,21 @@ is a separate error indicator for each thread.
Either alphabetical or some kind of structure.
-.. cfunction:: void PyErr_Print()
+.. cfunction:: void PyErr_PrintEx(int set_sys_last_vars)
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
Call this function only when the error indicator is set. (Otherwise it will
cause a fatal error!)
+ If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
+ :data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
+ type, value and traceback of the printed exception, respectively.
+
+
+.. cfunction:: void PyErr_Print()
+
+ Alias for ``PyErr_PrintEx(1)``.
+
.. cfunction:: PyObject* PyErr_Occurred()
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index a4a202a..077efbc 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -353,18 +353,36 @@ Initialization, Finalization, and Threads
single: Py_FatalError()
single: argv (in module sys)
- Set ``sys.argv`` based on *argc* and *argv*. These parameters are similar to
- those passed to the program's :cfunc:`main` function with the difference that
- the first entry should refer to the script file to be executed rather than the
- executable hosting the Python interpreter. If there isn't a script that will be
- run, the first entry in *argv* can be an empty string. If this function fails
- to initialize ``sys.argv``, a fatal condition is signalled using
- :cfunc:`Py_FatalError`.
+ Set :data:`sys.argv` based on *argc* and *argv*. These parameters are
+ similar to those passed to the program's :cfunc:`main` function with the
+ difference that the first entry should refer to the script file to be
+ executed rather than the executable hosting the Python interpreter. If there
+ isn't a script that will be run, the first entry in *argv* can be an empty
+ string. If this function fails to initialize :data:`sys.argv`, a fatal
+ condition is signalled using :cfunc:`Py_FatalError`.
+
+ This function also prepends the executed script's path to :data:`sys.path`.
+ If no script is executed (in the case of calling ``python -c`` or just the
+ interactive interpreter), the empty string is used instead.
.. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
check w/ Guido.
+.. cfunction:: void Py_SetPythonHome(char *home)
+
+ Set the default "home" directory, that is, the location of the standard
+ Python libraries. The libraries are searched in
+ :file:`{home}/lib/python{version}` and :file:`{home}/lib/python{version}`.
+
+
+.. cfunction:: char* Py_GetPythonHome()
+
+ Return the default "home", that is, the value set by a previous call to
+ :cfunc:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
+ environment variable if it is set.
+
+
.. _threads:
Thread State and the Global Interpreter Lock
diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
index 9befaf7..e8a3fc4 100644
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -187,7 +187,7 @@ caller is said to receive a *new* reference. When no ownership is transferred,
the caller is said to *borrow* the reference. Nothing needs to be done for a
borrowed reference.
-Conversely, when a calling function passes it a reference to an object, there
+Conversely, when a calling function passes in a reference to an object, there
are two possibilities: the function *steals* a reference to the object, or it
does not. *Stealing a reference* means that when you pass a reference to a
function, that function assumes that it now owns that reference, and you are not
diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst
index 6a3f91d..6811bc8 100644
--- a/Doc/c-api/veryhigh.rst
+++ b/Doc/c-api/veryhigh.rst
@@ -16,7 +16,7 @@ parameter. The available start symbols are :const:`Py_eval_input`,
:const:`Py_file_input`, and :const:`Py_single_input`. These are described
following the functions which accept them as parameters.
-Note also that several of these functions take :ctype:`FILE\*` parameters. On
+Note also that several of these functions take :ctype:`FILE\*` parameters. One
particular issue which needs to be handled carefully is that the :ctype:`FILE`
structure for different C libraries can be different and incompatible. Under
Windows (at least), it is possible for dynamically linked extensions to actually
diff --git a/Doc/documenting/markup.rst b/Doc/documenting/markup.rst
index 80b43b9..3ca8983 100644
--- a/Doc/documenting/markup.rst
+++ b/Doc/documenting/markup.rst
@@ -285,14 +285,27 @@ Inline markup
As said before, Sphinx uses interpreted text roles to insert semantic markup in
documents.
-Variable names are an exception, they should be marked simply with ``*var*``.
+Names of local variables, such as function/method arguments, are an exception,
+they should be marked simply with ``*var*``.
For all other roles, you have to write ``:rolename:`content```.
-.. note::
+There are some additional facilities that make cross-referencing roles more
+versatile:
+
+* You may supply an explicit title and reference target, like in reST direct
+ hyperlinks: ``:role:`title <target>``` will refer to *target*, but the link
+ text will be *title*.
+
+* If you prefix the content with ``!``, no reference/hyperlink will be created.
+
+* For the Python object roles, if you prefix the content with ``~``, the link
+ text will only be the last component of the target. For example,
+ ``:meth:`~Queue.Queue.get``` will refer to ``Queue.Queue.get`` but only
+ display ``get`` as the link text.
- For all cross-referencing roles, if you prefix the content with ``!``, no
- reference/hyperlink will be created.
+ In HTML output, the link's ``title`` attribute (that is e.g. shown as a
+ tool-tip on mouse-hover) will always be the full target name.
The following roles refer to objects in modules and are possibly hyperlinked if
a matching identifier is found:
@@ -310,7 +323,7 @@ a matching identifier is found:
.. describe:: data
- The name of a module-level variable.
+ The name of a module-level variable or constant.
.. describe:: const
diff --git a/Doc/howto/webservers.rst b/Doc/howto/webservers.rst
index 6e0c815..62c9124 100644
--- a/Doc/howto/webservers.rst
+++ b/Doc/howto/webservers.rst
@@ -99,7 +99,8 @@ simple CGI program::
# -*- coding: UTF-8 -*-
# enable debugging
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
print "Content-Type: text/plain;charset=utf-8"
print
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst
index 68a941f..084660d 100644
--- a/Doc/library/base64.rst
+++ b/Doc/library/base64.rst
@@ -63,7 +63,8 @@ The modern interface, which was introduced in Python 2.4, provides:
.. function:: urlsafe_b64encode(s)
Encode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of
- ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet.
+ ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. The result
+ can still contain ``=``.
.. function:: urlsafe_b64decode(s)
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst
index 0248284..3879e0d 100644
--- a/Doc/library/cgi.rst
+++ b/Doc/library/cgi.rst
@@ -67,16 +67,18 @@ Begin by writing ``import cgi``. Do not use ``from cgi import *`` --- the
module defines all sorts of names for its own use or for backward compatibility
that you don't want in your namespace.
-When you write a new script, consider adding the line::
+When you write a new script, consider adding these lines::
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
This activates a special exception handler that will display detailed reports in
the Web browser if any errors occur. If you'd rather not show the guts of your
program to users of your script, you can have the reports saved to files
-instead, with a line like this::
+instead, with code like this::
- import cgitb; cgitb.enable(display=0, logdir="/tmp")
+ import cgitb
+ cgitb.enable(display=0, logdir="/tmp")
It's very helpful to use this feature during script development. The reports
produced by :mod:`cgitb` provide information that can save you a lot of time in
@@ -470,9 +472,10 @@ discarded altogether.
Fortunately, once you have managed to get your script to execute *some* code,
you can easily send tracebacks to the Web browser using the :mod:`cgitb` module.
-If you haven't done so already, just add the line::
+If you haven't done so already, just add the lines::
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
to the top of your script. Then try running it again; when a problem occurs,
you should see a detailed report that will likely make apparent the cause of the
diff --git a/Doc/library/cgitb.rst b/Doc/library/cgitb.rst
index 327cd17..052b821 100644
--- a/Doc/library/cgitb.rst
+++ b/Doc/library/cgitb.rst
@@ -26,9 +26,10 @@ as well as the values of the arguments and local variables to currently running
functions, to help you debug the problem. Optionally, you can save this
information to a file instead of sending it to the browser.
-To enable this feature, simply add one line to the top of your CGI script::
+To enable this feature, simply add this to the top of your CGI script::
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
The options to the :func:`enable` function control whether the report is
displayed in the browser and whether the report is logged to a file for later
diff --git a/Doc/library/cookielib.rst b/Doc/library/cookielib.rst
index f55d6c2..12a12a0 100644
--- a/Doc/library/cookielib.rst
+++ b/Doc/library/cookielib.rst
@@ -769,7 +769,7 @@ returned::
import urllib2
from cookielib import CookieJar, DefaultCookiePolicy
policy = DefaultCookiePolicy(
- rfc2965=True, strict_ns_domain=Policy.DomainStrict,
+ rfc2965=True, strict_ns_domain=DefaultCookiePolicy.DomainStrict,
blocked_domains=["ads.net", ".ads.net"])
cj = CookieJar(policy)
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 9ff3de0..c7c3b00 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1274,6 +1274,7 @@ library to load.
.. data:: find_library(name)
+ :module: ctypes.util
:noindex:
Try to find a library and return a pathname. *name* is the library name without
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 637326d..0996276 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -1497,11 +1497,10 @@ For :class:`date` objects, the format codes for hours, minutes, seconds, and
microseconds should not be used, as :class:`date` objects have no such
values. If they're used anyway, ``0`` is substituted for them.
-:class:`time` and :class:`datetime` objects support a ``%f`` format code
-which expands to the number of microseconds in the object, zero-padded on
-the left to six places.
-
.. versionadded:: 2.6
+ :class:`time` and :class:`datetime` objects support a ``%f`` format code
+ which expands to the number of microseconds in the object, zero-padded on
+ the left to six places.
For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
strings.
@@ -1621,7 +1620,9 @@ Notes:
(1)
When used with the :func:`strptime` function, the ``%f`` directive
accepts from one to six digits and zero pads on the right. ``%f`` is
- an extension to the set of format characters in the C standard.
+ an extension to the set of format characters in the C standard (but
+ implemented separately in datetime objects, and therefore always
+ available).
(2)
When used with the :func:`strptime` function, the ``%p`` directive only affects
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 01b54b3..9673dab 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -398,6 +398,11 @@ The following exceptions are the exceptions that are actually raised.
more precise exception such as :exc:`IndexError`.
+.. exception:: VMSError
+
+ Only available on VMS. Raised when a VMS-specific error occurs.
+
+
.. exception:: WindowsError
Raised when a Windows-specific error occurs or when the error number does not
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 63a2e3e..7a31323 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -425,6 +425,26 @@ available. They are listed here in alphabetical order.
The float type is described in :ref:`typesnumeric`.
+
+.. function:: format(value[, format_spec])
+
+ .. index::
+ pair: str; format
+ single: __format__
+
+ Convert a *value* to a "formatted" representation, as controlled by
+ *format_spec*. The interpretation of *format_spec* will depend on the type
+ of the *value* argument, however there is a standard formatting syntax that
+ is used by most built-in types: :ref:`formatspec`.
+
+ .. note::
+
+ ``format(value, format_spec)`` merely calls
+ ``value.__format__(format_spec)``.
+
+ .. versionadded:: 2.6
+
+
.. function:: frozenset([iterable])
:noindex:
@@ -1178,8 +1198,10 @@ available. They are listed here in alphabetical order.
If the second argument is omitted the super
object returned is unbound. If the second argument is an object,
``isinstance(obj, type)`` must be true. If the second argument is a type,
- ``issubclass(type2, type)`` must be true. :func:`super` only works for
- :term:`new-style class`\es.
+ ``issubclass(type2, type)`` must be true.
+
+ .. note::
+ :func:`super` only works for :term:`new-style class`\es.
There are two typical use cases for "super". In a class hierarchy with
single inheritance, "super" can be used to refer to parent classes without
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst
index 6af4074..4ef2ba7 100644
--- a/Doc/library/optparse.rst
+++ b/Doc/library/optparse.rst
@@ -1511,7 +1511,7 @@ Here's an example of a callback option that takes no arguments, and simply
records that the option was seen::
def record_foo_seen(option, opt_str, value, parser):
- parser.saw_foo = True
+ parser.values.saw_foo = True
parser.add_option("--foo", action="callback", callback=record_foo_seen)
@@ -1651,7 +1651,7 @@ arguments::
value.append(arg)
del parser.rargs[:len(value)]
- setattr(parser.values, option.dest, value))
+ setattr(parser.values, option.dest, value)
[...]
parser.add_option("-c", "--callback", dest="vararg_attr",
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 63c4bc7..9e55665 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -188,13 +188,13 @@ be found in any statistics text.
.. function:: uniform(a, b)
- Return a random floating point number *N* such that ``a <= N < b`` for
- ``a <= b`` and ``b <= N < a`` for ``b < a``.
+ Return a random floating point number *N* such that ``a <= N <= b`` for
+ ``a <= b`` and ``b <= N <= a`` for ``b < a``.
.. function:: triangular(low, high, mode)
- Return a random floating point number *N* such that ``low <= N < high`` and
+ Return a random floating point number *N* such that ``low <= N <= high`` and
with the specified *mode* between those bounds. The *low* and *high* bounds
default to zero and one. The *mode* argument defaults to the midpoint
between the bounds, giving a symmetric distribution.
@@ -204,8 +204,8 @@ be found in any statistics text.
.. function:: betavariate(alpha, beta)
- Beta distribution. Conditions on the parameters are ``alpha > 0`` and ``beta >
- 0``. Returned values range between 0 and 1.
+ Beta distribution. Conditions on the parameters are ``alpha > 0`` and
+ ``beta > 0``. Returned values range between 0 and 1.
.. function:: expovariate(lambd)
@@ -219,14 +219,15 @@ be found in any statistics text.
.. function:: gammavariate(alpha, beta)
- Gamma distribution. (*Not* the gamma function!) Conditions on the parameters
- are ``alpha > 0`` and ``beta > 0``.
+ Gamma distribution. (*Not* the gamma function!) Conditions on the
+ parameters are ``alpha > 0`` and ``beta > 0``.
.. function:: gauss(mu, sigma)
- Gaussian distribution. *mu* is the mean, and *sigma* is the standard deviation.
- This is slightly faster than the :func:`normalvariate` function defined below.
+ Gaussian distribution. *mu* is the mean, and *sigma* is the standard
+ deviation. This is slightly faster than the :func:`normalvariate` function
+ defined below.
.. function:: lognormvariate(mu, sigma)
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index 6ae9038..a4f181b 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -517,7 +517,7 @@ An example for the :class:`ThreadingMixIn` class::
# Exit the server thread when the main thread terminates
server_thread.setDaemon(True)
server_thread.start()
- print "Server loop running in thread:", t.getName()
+ print "Server loop running in thread:", server_thread.getName()
client(ip, port, "Hello World 1")
client(ip, port, "Hello World 2")
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 1ee7ea2..0434ff2 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -375,7 +375,7 @@ All :class:`numbers.Real` types (:class:`int`, :class:`long`, and
+--------------------+------------------------------------+--------+
| Operation | Result | Notes |
+====================+====================================+========+
-| ``trunc(x)`` | *x* truncated to Integral | |
+| ``math.trunc(x)`` | *x* truncated to Integral | |
+--------------------+------------------------------------+--------+
| ``round(x[, n])`` | *x* rounded to n digits, | |
| | rounding half to even. If n is | |
@@ -601,9 +601,9 @@ Sequence Types --- :class:`str`, :class:`unicode`, :class:`list`, :class:`tuple`
There are six sequence types: strings, Unicode strings, lists, tuples, buffers,
and xrange objects.
-(For other containers see the built in :class:`dict`, :class:`list`,
-:class:`set`, and :class:`tuple` classes, and the :mod:`collections`
-module.)
+
+For other containers see the built in :class:`dict` and :class:`set` classes,
+and the :mod:`collections` module.
.. index::
@@ -1648,7 +1648,7 @@ The constructors for both classes work the same:
.. method:: union(other, ...)
set | other | ...
- Return a new set with elements from both sets.
+ Return a new set with elements from the set and all others.
.. versionchanged:: 2.6
Accepts multiple input iterables.
@@ -1656,7 +1656,7 @@ The constructors for both classes work the same:
.. method:: intersection(other, ...)
set & other & ...
- Return a new set with elements common to both sets.
+ Return a new set with elements common to the set and all others.
.. versionchanged:: 2.6
Accepts multiple input iterables.
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 85860e5..e6616db 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -210,7 +210,7 @@ changed through the :attr:`name` attribute.
A thread can be flagged as a "daemon thread". The significance of this flag is
that the entire Python program exits when only daemon threads are left. The
initial value is inherited from the creating thread. The flag can be set
-through the :attr:`daemon` attribute.
+through the :attr:`daemon` property.
There is a "main thread" object; this corresponds to the initial thread of
control in the Python program. It is not a daemon thread.
@@ -332,10 +332,11 @@ impossible to detect the termination of alien threads.
.. attribute:: Thread.daemon
- The thread's daemon flag. This must be set before :meth:`start` is called,
- otherwise :exc:`RuntimeError` is raised.
-
- The initial value is inherited from the creating thread.
+ A boolean value indicating whether this thread is a daemon thread (True) or
+ not (False). This must be set before :meth:`start` is called, otherwise
+ :exc:`RuntimeError` is raised. Its initial value is inherited from the
+ creating thread; the main thread is not a daemon thread and therefore all
+ threads created in the main thread default to :attr:`daemon` = ``False``.
The entire Python program exits when no alive non-daemon threads are left.
diff --git a/Doc/library/urllib2.rst b/Doc/library/urllib2.rst
index 986e545..e6f8061 100644
--- a/Doc/library/urllib2.rst
+++ b/Doc/library/urllib2.rst
@@ -602,14 +602,15 @@ HTTPRedirectHandler Objects
precise meanings of the various redirection codes.
-.. method:: HTTPRedirectHandler.redirect_request(req, fp, code, msg, hdrs)
+.. method:: HTTPRedirectHandler.redirect_request(req, fp, code, msg, hdrs, newurl)
Return a :class:`Request` or ``None`` in response to a redirect. This is called
by the default implementations of the :meth:`http_error_30\*` methods when a
redirection is received from the server. If a redirection should take place,
return a new :class:`Request` to allow :meth:`http_error_30\*` to perform the
- redirect. Otherwise, raise :exc:`HTTPError` if no other handler should try to
- handle this URL, or return ``None`` if you can't but another handler might.
+ redirect to *newurl*. Otherwise, raise :exc:`HTTPError` if no other handler
+ should try to handle this URL, or return ``None`` if you can't but another
+ handler might.
.. note::
@@ -622,8 +623,8 @@ HTTPRedirectHandler Objects
.. method:: HTTPRedirectHandler.http_error_301(req, fp, code, msg, hdrs)
- Redirect to the ``Location:`` URL. This method is called by the parent
- :class:`OpenerDirector` when getting an HTTP 'moved permanently' response.
+ Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the
+ parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response.
.. method:: HTTPRedirectHandler.http_error_302(req, fp, code, msg, hdrs)
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index 9aa1ea3..38545c2 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -529,5 +529,5 @@ This is an example of counting the maximum depth of an XML file::
.. [#] The encoding string included in XML output should conform to the
appropriate standards. For example, "UTF-8" is valid, but "UTF8" is
not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl
- and http://www.iana.org/assignments/character-sets .
+ and http://www.iana.org/assignments/character-sets.
diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst
index 039a8a8..4035f8e 100644
--- a/Doc/library/xmlrpclib.rst
+++ b/Doc/library/xmlrpclib.rst
@@ -318,9 +318,8 @@ XMLRPC::
import xmlrpclib
def python_logo():
- handle = open("python_logo.jpg")
- return xmlrpclib.Binary(handle.read())
- handle.close()
+ with open("python_logo.jpg") as handle:
+ return xmlrpclib.Binary(handle.read())
server = SimpleXMLRPCServer(("localhost", 8000))
print "Listening on port 8000..."
@@ -333,9 +332,8 @@ The client gets the image and saves it to a file::
import xmlrpclib
proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
- handle = open("fetched_python_logo.jpg", "w")
- handle.write(proxy.python_logo().data)
- handle.close()
+ with open("fetched_python_logo.jpg", "w") as handle:
+ handle.write(proxy.python_logo().data)
.. _fault-objects:
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: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
: | ">>=" | "<<=" | "&=" | "^=" | "|="
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py
index 3ea04bd..0c19003 100755
--- a/Doc/tools/rstlint.py
+++ b/Doc/tools/rstlint.py
@@ -6,6 +6,9 @@
#
# 01/2009, Georg Brandl
+# TODO: - wrong versions in versionadded/changed
+# - wrong markup after versionchanged directive
+
from __future__ import with_statement
import os
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py
index 48ce6da..688de95 100644
--- a/Doc/tools/sphinxext/pyspecific.py
+++ b/Doc/tools/sphinxext/pyspecific.py
@@ -13,6 +13,14 @@ ISSUE_URI = 'http://bugs.python.org/issue%s'
from docutils import nodes, utils
+# monkey-patch reST parser to disable alphabetic and roman enumerated lists
+from docutils.parsers.rst.states import Body
+Body.enum.converters['loweralpha'] = \
+ Body.enum.converters['upperalpha'] = \
+ Body.enum.converters['lowerroman'] = \
+ Body.enum.converters['upperroman'] = lambda x: None
+
+
def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
issue = utils.unescape(text)
text = 'issue ' + issue
diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst
index e1e2887..ca87dbb 100644
--- a/Doc/whatsnew/2.5.rst
+++ b/Doc/whatsnew/2.5.rst
@@ -1761,8 +1761,8 @@ ElementTree 1.2.6. The :mod:`cElementTree` accelerator module is also
included.
The rest of this section will provide a brief overview of using ElementTree.
-Full documentation for ElementTree is available at http://effbot.org/zone
-/element-index.htm.
+Full documentation for ElementTree is available at
+http://effbot.org/zone/element-index.htm.
ElementTree represents an XML document as a tree of element nodes. The text
content of the document is stored as the :attr:`.text` and :attr:`.tail`