summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-09-02 15:30:55 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-09-02 15:30:55 (GMT)
commit677dc7189f6c79f1a534f6e8de89758593934cb3 (patch)
treec3ceccca3092ca421e6e7c351d0dd190378f4d4e /Doc/library
parent6c78de55fcb0c0894fd81bc3c9b43a19207fa9c3 (diff)
parent793c47a88a8ad3b1e113308fa9cd359fb3819879 (diff)
downloadcpython-677dc7189f6c79f1a534f6e8de89758593934cb3.zip
cpython-677dc7189f6c79f1a534f6e8de89758593934cb3.tar.gz
cpython-677dc7189f6c79f1a534f6e8de89758593934cb3.tar.bz2
Branch merge
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/argparse.rst2
-rw-r--r--Doc/library/base64.rst4
-rw-r--r--Doc/library/configparser.rst6
-rw-r--r--Doc/library/email.header.rst4
-rw-r--r--Doc/library/functions.rst36
-rw-r--r--Doc/library/inspect.rst8
-rw-r--r--Doc/library/packaging.util.rst37
-rw-r--r--Doc/library/stdtypes.rst4
-rw-r--r--Doc/library/string.rst2
-rw-r--r--Doc/library/unittest.rst28
10 files changed, 59 insertions, 72 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index af40888..5a211e1 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -155,7 +155,7 @@ ArgumentParser objects
conflicting optionals.
* prog_ - The name of the program (default:
- :data:`sys.argv[0]`)
+ ``sys.argv[0]``)
* usage_ - The string describing the program usage (default: generated)
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst
index 2401ae7..06f3ab1 100644
--- a/Doc/library/base64.rst
+++ b/Doc/library/base64.rst
@@ -45,8 +45,8 @@ The modern interface provides:
at least length 2 (additional characters are ignored) which specifies the
alternative alphabet used instead of the ``+`` and ``/`` characters.
- The decoded string is returned. A `binascii.Error` is raised if *s* is
- incorrectly padded.
+ The decoded string is returned. A :exc:`binascii.Error` exception is raised
+ if *s* is incorrectly padded.
If *validate* is ``False`` (the default), non-base64-alphabet characters are
discarded prior to the padding check. If *validate* is ``True``,
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index c84e423..0c68b03 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -806,17 +806,17 @@ To get interpolation, use :class:`ConfigParser`::
cfg = configparser.ConfigParser()
cfg.read('example.cfg')
- # Set the optional `raw` argument of get() to True if you wish to disable
+ # Set the optional *raw* argument of get() to True if you wish to disable
# interpolation in a single get operation.
print(cfg.get('Section1', 'foo', raw=False)) # -> "Python is fun!"
print(cfg.get('Section1', 'foo', raw=True)) # -> "%(bar)s is %(baz)s!"
- # The optional `vars` argument is a dict with members that will take
+ # The optional *vars* argument is a dict with members that will take
# precedence in interpolation.
print(cfg.get('Section1', 'foo', vars={'bar': 'Documentation',
'baz': 'evil'}))
- # The optional `fallback` argument can be used to provide a fallback value
+ # The optional *fallback* argument can be used to provide a fallback value
print(cfg.get('Section1', 'foo'))
# -> "Python is fun!"
diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst
index c385cf3..47a0749 100644
--- a/Doc/library/email.header.rst
+++ b/Doc/library/email.header.rst
@@ -141,11 +141,11 @@ Here is the :class:`Header` class description:
Returns an approximation of the :class:`Header` as a string, using an
unlimited line length. All pieces are converted to unicode using the
specified encoding and joined together appropriately. Any pieces with a
- charset of `unknown-8bit` are decoded as `ASCII` using the `replace`
+ charset of ``'unknown-8bit'`` are decoded as ASCII using the ``'replace'``
error handler.
.. versionchanged:: 3.2
- Added handling for the `unknown-8bit` charset.
+ Added handling for the ``'unknown-8bit'`` charset.
.. method:: __eq__(other)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 3b6fdc3..4ed3ec5 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -10,7 +10,7 @@ are always available. They are listed here in alphabetical order.
=================== ================= ================== ================ ====================
.. .. Built-in Functions .. ..
=================== ================= ================== ================ ====================
-:func:`abs` :func:`dict` :func:`help` :func:`min` :func:`setattr`
+:func:`abs` |func-dict|_ :func:`help` :func:`min` :func:`setattr`
:func:`all` :func:`dir` :func:`hex` :func:`next` :func:`slice`
:func:`any` :func:`divmod` :func:`id` :func:`object` :func:`sorted`
:func:`ascii` :func:`enumerate` :func:`input` :func:`oct` :func:`staticmethod`
@@ -19,13 +19,22 @@ are always available. They are listed here in alphabetical order.
:func:`bytearray` :func:`filter` :func:`issubclass` :func:`pow` :func:`super`
:func:`bytes` :func:`float` :func:`iter` :func:`print` :func:`tuple`
:func:`callable` :func:`format` :func:`len` :func:`property` :func:`type`
-:func:`chr` :func:`frozenset` :func:`list` :func:`range` :func:`vars`
+:func:`chr` |func-frozenset|_ :func:`list` :func:`range` :func:`vars`
:func:`classmethod` :func:`getattr` :func:`locals` :func:`repr` :func:`zip`
:func:`compile` :func:`globals` :func:`map` :func:`reversed` :func:`__import__`
:func:`complex` :func:`hasattr` :func:`max` :func:`round`
-:func:`delattr` :func:`hash` :func:`memoryview` :func:`set`
+:func:`delattr` :func:`hash` |func-memoryview|_ |func-set|_
=================== ================= ================== ================ ====================
+.. using :func:`dict` would create a link to another page, so local targets are
+ used, with replacement texts to make the output in the table consistent
+
+.. |func-dict| replace:: ``dict()``
+.. |func-frozenset| replace:: ``frozenset()``
+.. |func-memoryview| replace:: ``memoryview()``
+.. |func-set| replace:: ``set()``
+
+
.. function:: abs(x)
Return the absolute value of a number. The argument may be an
@@ -74,11 +83,12 @@ are always available. They are listed here in alphabetical order.
.. function:: bool([x])
- Convert a value to a Boolean, using the standard truth testing procedure. If
- *x* is false or omitted, this returns :const:`False`; otherwise it returns
- :const:`True`. :class:`bool` is also a class, which is a subclass of
- :class:`int`. Class :class:`bool` cannot be subclassed further. Its only
- instances are :const:`False` and :const:`True`.
+ Convert a value to a Boolean, using the standard :ref:`truth testing
+ procedure <truth>`. If *x* is false or omitted, this returns ``False``;
+ otherwise it returns ``True``. :class:`bool` is also a class, which is a
+ subclass of :class:`int` (see :ref:`typesnumeric`). Class :class:`bool`
+ cannot be subclassed further. Its only instances are ``False`` and
+ ``True`` (see :ref:`bltin-boolean-values`).
.. index:: pair: Boolean; type
@@ -248,6 +258,7 @@ are always available. They are listed here in alphabetical order.
example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``.
+.. _func-dict:
.. function:: dict([arg])
:noindex:
@@ -491,6 +502,7 @@ are always available. They are listed here in alphabetical order.
The float type is described in :ref:`typesnumeric`.
+
.. function:: format(value[, format_spec])
.. index::
@@ -511,6 +523,8 @@ are always available. They are listed here in alphabetical order.
:exc:`TypeError` exception is raised if the method is not found or if either
the *format_spec* or the return value are not strings.
+
+.. _func-frozenset:
.. function:: frozenset([iterable])
:noindex:
@@ -717,6 +731,8 @@ are always available. They are listed here in alphabetical order.
such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and
``heapq.nlargest(1, iterable, key=keyfunc)``.
+
+.. _func-memoryview:
.. function:: memoryview(obj)
:noindex:
@@ -1040,7 +1056,7 @@ are always available. They are listed here in alphabetical order.
Range objects implement the :class:`collections.Sequence` ABC, and provide
features such as containment tests, element index lookup, slicing and
- support for negative indices:
+ support for negative indices (see :ref:`typesseq`):
>>> r = range(0, 20, 2)
>>> r
@@ -1108,6 +1124,8 @@ are always available. They are listed here in alphabetical order.
can't be represented exactly as a float. See :ref:`tut-fp-issues` for
more information.
+
+.. _func-set:
.. function:: set([iterable])
:noindex:
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 7a57a0d..d127ce8 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -575,13 +575,13 @@ properties, will be invoked and :meth:`__getattr__` and :meth:`__getattribute__`
may be called.
For cases where you want passive introspection, like documentation tools, this
-can be inconvenient. `getattr_static` has the same signature as :func:`getattr`
+can be inconvenient. :func:`getattr_static` has the same signature as :func:`getattr`
but avoids executing code when it fetches attributes.
.. function:: getattr_static(obj, attr, default=None)
Retrieve attributes without triggering dynamic lookup via the
- descriptor protocol, `__getattr__` or `__getattribute__`.
+ descriptor protocol, :meth:`__getattr__` or :meth:`__getattribute__`.
Note: this function may not be able to retrieve all attributes
that getattr can fetch (like dynamically created attributes)
@@ -589,12 +589,12 @@ but avoids executing code when it fetches attributes.
that raise AttributeError). It can also return descriptors objects
instead of instance members.
- If the instance `__dict__` is shadowed by another member (for example a
+ If the instance :attr:`__dict__` is shadowed by another member (for example a
property) then this function will be unable to find instance members.
.. versionadded:: 3.2
-`getattr_static` does not resolve descriptors, for example slot descriptors or
+:func:`getattr_static` does not resolve descriptors, for example slot descriptors or
getset descriptors on objects implemented in C. The descriptor object
is returned instead of the underlying attribute.
diff --git a/Doc/library/packaging.util.rst b/Doc/library/packaging.util.rst
index b95d5b5..019f3e9 100644
--- a/Doc/library/packaging.util.rst
+++ b/Doc/library/packaging.util.rst
@@ -90,34 +90,6 @@ This module contains various helpers for the other modules.
Search the path for a given executable name.
-.. function:: subst_vars(s, local_vars)
-
- Perform shell/Perl-style variable substitution on *s*. Every occurrence of
- ``$`` followed by a name is considered a variable, and variable is
- substituted by the value found in the *local_vars* dictionary, or in
- ``os.environ`` if it's not in *local_vars*. *os.environ* is first
- checked/augmented to guarantee that it contains certain values: see
- :func:`check_environ`. Raise :exc:`ValueError` for any variables not found
- in either *local_vars* or ``os.environ``.
-
- Note that this is not a fully-fledged string interpolation function. A valid
- ``$variable`` can consist only of upper and lower case letters, numbers and
- an underscore. No { } or ( ) style quoting is available.
-
-
-.. function:: split_quoted(s)
-
- Split a string up according to Unix shell-like rules for quotes and
- backslashes. In short: words are delimited by spaces, as long as those spaces
- are not escaped by a backslash, or inside a quoted string. Single and double
- quotes are equivalent, and the quote characters can be backslash-escaped.
- The backslash is stripped from any two-character escape sequence, leaving
- only the escaped character. The quote characters are stripped from any
- quoted string. Returns a list of words.
-
- .. TODO Should probably be moved into the standard library.
-
-
.. function:: execute(func, args[, msg=None, verbose=0, dry_run=0])
Perform some action that affects the outside world (for instance, writing to
@@ -175,12 +147,3 @@ This module contains various helpers for the other modules.
figure out to use direct compilation or not (see the source for details).
The *direct* flag is used by the script generated in indirect mode; unless
you know what you're doing, leave it set to ``None``.
-
-
-.. function:: rfc822_escape(header)
-
- Return a version of *header* escaped for inclusion in an :rfc:`822` header, by
- ensuring there are 8 spaces space after each newline. Note that it does no
- other modification of the string.
-
- .. TODO this _can_ be replaced
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index a5f0d59..46f0f9f 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2724,6 +2724,8 @@ special operations. There is exactly one ellipsis object, named
It is written as ``Ellipsis`` or ``...``.
+.. _bltin-notimplemented-object:
+
The NotImplemented Object
-------------------------
@@ -2735,6 +2737,8 @@ information. There is exactly one ``NotImplemented`` object.
It is written as ``NotImplemented``.
+.. _bltin-boolean-values:
+
Boolean Values
--------------
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index 2443180..78f2b4d 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -216,6 +216,8 @@ keyword. If it's a number, it refers to a positional argument, and if it's a ke
it refers to a named keyword argument. If the numerical arg_names in a format string
are 0, 1, 2, ... in sequence, they can all be omitted (not just some)
and the numbers 0, 1, 2, ... will be automatically inserted in that order.
+Because *arg_name* is not quote-delimited, it is not possible to specify arbitrary
+dictionary keys (e.g., the strings ``'10'`` or ``':-]'``) within a format string.
The *arg_name* can be followed by any number of index or
attribute expressions. An expression of the form ``'.name'`` selects the named
attribute using :func:`getattr`, while an expression of the form ``'[index]'``
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 191d5b9..7340588 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -293,7 +293,7 @@ used from the command line. The basic command-line usage is::
As a shortcut, ``python -m unittest`` is the equivalent of
``python -m unittest discover``. If you want to pass arguments to test
- discovery the `discover` sub-command must be used explicitly.
+ discovery the ``discover`` sub-command must be used explicitly.
The ``discover`` sub-command has the following options:
@@ -305,11 +305,11 @@ The ``discover`` sub-command has the following options:
.. cmdoption:: -s directory
- Directory to start discovery ('.' default)
+ Directory to start discovery (``.`` default)
.. cmdoption:: -p pattern
- Pattern to match test files ('test*.py' default)
+ Pattern to match test files (``test*.py`` default)
.. cmdoption:: -t directory
@@ -724,8 +724,8 @@ Test cases
single test.
.. versionchanged:: 3.2
- `TestCase` can be instantiated successfully without providing a method
- name. This makes it easier to experiment with `TestCase` from the
+ :class:`TestCase` can be instantiated successfully without providing a method
+ name. This makes it easier to experiment with :class:`TestCase` from the
interactive interpreter.
*methodName* defaults to :meth:`runTest`.
@@ -944,17 +944,17 @@ Test cases
+---------------------------------------------------------+--------------------------------------+------------+
| Method | Checks that | New in |
+=========================================================+======================================+============+
- | :meth:`assertRaises(exc, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises `exc` | |
+ | :meth:`assertRaises(exc, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | |
| <TestCase.assertRaises>` | | |
+---------------------------------------------------------+--------------------------------------+------------+
- | :meth:`assertRaisesRegex(exc, re, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises `exc` | 3.1 |
- | <TestCase.assertRaisesRegex>` | and the message matches `re` | |
+ | :meth:`assertRaisesRegex(exc, re, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | 3.1 |
+ | <TestCase.assertRaisesRegex>` | and the message matches *re* | |
+---------------------------------------------------------+--------------------------------------+------------+
- | :meth:`assertWarns(warn, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises `warn` | 3.2 |
+ | :meth:`assertWarns(warn, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *warn* | 3.2 |
| <TestCase.assertWarns>` | | |
+---------------------------------------------------------+--------------------------------------+------------+
- | :meth:`assertWarnsRegex(warn, re, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises `warn` | 3.2 |
- | <TestCase.assertWarnsRegex>` | and the message matches `re` | |
+ | :meth:`assertWarnsRegex(warn, re, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *warn* | 3.2 |
+ | <TestCase.assertWarnsRegex>` | and the message matches *re* | |
+---------------------------------------------------------+--------------------------------------+------------+
.. method:: assertRaises(exception, callable, *args, **kwds)
@@ -1116,7 +1116,7 @@ Test cases
| :meth:`assertNotRegex(s, re) | ``not regex.search(s)`` | 3.2 |
| <TestCase.assertNotRegex>` | | |
+---------------------------------------+--------------------------------+--------------+
- | :meth:`assertCountEqual(a, b) | `a` and `b` have the same | 3.2 |
+ | :meth:`assertCountEqual(a, b) | *a* and *b* have the same | 3.2 |
| <TestCase.assertCountEqual>` | elements in the same number, | |
| | regardless of their order | |
+---------------------------------------+--------------------------------+--------------+
@@ -1911,7 +1911,7 @@ Loading and running tests
.. class:: TextTestRunner(stream=None, descriptions=True, verbosity=1, runnerclass=None, warnings=None)
A basic test runner implementation that outputs results to a stream. If *stream*
- is `None`, the default, `sys.stderr` is used as the output stream. This class
+ is ``None``, the default, :data:`sys.stderr` is used as the output stream. This class
has a few configurable parameters, but is essentially very simple. Graphical
applications which run test suites should provide alternate implementations.
@@ -1928,7 +1928,7 @@ Loading and running tests
Added the ``warnings`` argument.
.. versionchanged:: 3.2
- The default stream is set to `sys.stderr` at instantiation time rather
+ The default stream is set to :data:`sys.stderr` at instantiation time rather
than import time.
.. method:: _makeResult()