[Python-checkins] r56993 - in doctools/trunk: Doc-26/library/anydbm.rst Doc-26/library/cmath.rst Doc-26/library/dbhash.rst Doc-26/library/dbm.rst Doc-26/library/filecmp.rst Doc-26/library/fileinput.rst Doc-26/library/functools.rst Doc-26/library/gdbm.rst Doc-26/library/itertools.rst Doc-26/library/marshal.rst Doc-26/library/operator.rst Doc-26/library/os.path.rst Doc-26/library/pickle.rst Doc-26/library/random.rst Doc-26/library/shutil.rst Doc-26/library/tempfile.rst Doc-3k/library/anydbm.rst Doc-3k/library/cmath.rst Doc-3k/library/dbhash.rst Doc-3k/library/dbm.rst Doc-3k/library/filecmp.rst Doc-3k/library/fileinput.rst Doc-3k/library/functools.rst Doc-3k/library/gdbm.rst Doc-3k/library/itertools.rst Doc-3k/library/marshal.rst Doc-3k/library/operator.rst Doc-3k/library/os.path.rst Doc-3k/library/pickle.rst Doc-3k/library/random.rst Doc-3k/library/shutil.rst Doc-3k/library/tempfile.rst TODO
georg.brandl
python-checkins at python.org
Mon Aug 13 22:52:58 CEST 2007
Author: georg.brandl
Date: Mon Aug 13 22:52:56 2007
New Revision: 56993
Modified:
doctools/trunk/Doc-26/library/anydbm.rst
doctools/trunk/Doc-26/library/cmath.rst
doctools/trunk/Doc-26/library/dbhash.rst
doctools/trunk/Doc-26/library/dbm.rst
doctools/trunk/Doc-26/library/filecmp.rst
doctools/trunk/Doc-26/library/fileinput.rst
doctools/trunk/Doc-26/library/functools.rst
doctools/trunk/Doc-26/library/gdbm.rst
doctools/trunk/Doc-26/library/itertools.rst
doctools/trunk/Doc-26/library/marshal.rst
doctools/trunk/Doc-26/library/operator.rst
doctools/trunk/Doc-26/library/os.path.rst
doctools/trunk/Doc-26/library/pickle.rst
doctools/trunk/Doc-26/library/random.rst
doctools/trunk/Doc-26/library/shutil.rst
doctools/trunk/Doc-26/library/tempfile.rst
doctools/trunk/Doc-3k/library/anydbm.rst
doctools/trunk/Doc-3k/library/cmath.rst
doctools/trunk/Doc-3k/library/dbhash.rst
doctools/trunk/Doc-3k/library/dbm.rst
doctools/trunk/Doc-3k/library/filecmp.rst
doctools/trunk/Doc-3k/library/fileinput.rst
doctools/trunk/Doc-3k/library/functools.rst
doctools/trunk/Doc-3k/library/gdbm.rst
doctools/trunk/Doc-3k/library/itertools.rst
doctools/trunk/Doc-3k/library/marshal.rst
doctools/trunk/Doc-3k/library/operator.rst
doctools/trunk/Doc-3k/library/os.path.rst
doctools/trunk/Doc-3k/library/pickle.rst
doctools/trunk/Doc-3k/library/random.rst
doctools/trunk/Doc-3k/library/shutil.rst
doctools/trunk/Doc-3k/library/tempfile.rst
doctools/trunk/TODO
Log:
More fixes by Tim Hatch.
Modified: doctools/trunk/Doc-26/library/anydbm.rst
==============================================================================
--- doctools/trunk/Doc-26/library/anydbm.rst (original)
+++ doctools/trunk/Doc-26/library/anydbm.rst Mon Aug 13 22:52:56 2007
@@ -41,8 +41,8 @@
.. exception:: error
A tuple containing the exceptions that can be raised by each of the supported
- modules, with a unique exception :exc:`anydbm.error` as the first item --- the
- latter is used when :exc:`anydbm.error` is raised.
+ modules, with a unique exception also named :exc:`anydbm.error` as the first
+ item --- the latter is used when :exc:`anydbm.error` is raised.
The object returned by :func:`open` supports most of the same functionality as
dictionaries; keys and their corresponding values can be stored, retrieved, and
Modified: doctools/trunk/Doc-26/library/cmath.rst
==============================================================================
--- doctools/trunk/Doc-26/library/cmath.rst (original)
+++ doctools/trunk/Doc-26/library/cmath.rst Mon Aug 13 22:52:56 2007
@@ -37,29 +37,30 @@
.. function:: asinh(x)
- Return the hyperbolic arc sine of *x*. There are two branch cuts, extending left
- from ±``1j`` to ±-∞``j``, both continuous from above. These branch cuts should
- be considered a bug to be corrected in a future release. The correct branch cuts
- should extend along the imaginary axis, one from ``1j`` up to ∞``j`` and
- continuous from the right, and one from -\ ``1j`` down to -∞``j`` and continuous
- from the left.
+ Return the hyperbolic arc sine of *x*. There are two branch cuts, extending
+ left from ``±1j`` to ``±∞j``, both continuous from above. These branch cuts
+ should be considered a bug to be corrected in a future release. The correct
+ branch cuts should extend along the imaginary axis, one from ``1j`` up to
+ ``∞j`` and continuous from the right, and one from ``-1j`` down to ``-∞j``
+ and continuous from the left.
.. function:: atan(x)
Return the arc tangent of *x*. There are two branch cuts: One extends from
- ``1j`` along the imaginary axis to ∞``j``, continuous from the left. The other
- extends from -\ ``1j`` along the imaginary axis to -∞``j``, continuous from the
- left. (This should probably be changed so the upper cut becomes continuous from
- the other side.)
+ ``1j`` along the imaginary axis to ``∞j``, continuous from the left. The
+ other extends from ``-1j`` along the imaginary axis to ``-∞j``, continuous
+ from the left. (This should probably be changed so the upper cut becomes
+ continuous from the other side.)
.. function:: atanh(x)
- Return the hyperbolic arc tangent of *x*. There are two branch cuts: One extends
- from 1 along the real axis to ∞, continuous from above. The other extends from
- -1 along the real axis to -∞, continuous from above. (This should probably be
- changed so the right cut becomes continuous from the other side.)
+ Return the hyperbolic arc tangent of *x*. There are two branch cuts: One
+ extends from ``1`` along the real axis to ``∞``, continuous from above. The
+ other extends from ``-1`` along the real axis to ``-∞``, continuous from
+ above. (This should probably be changed so the right cut becomes continuous
+ from the other side.)
.. function:: cos(x)
@@ -122,12 +123,12 @@
.. data:: pi
- The mathematical constant *pi*, as a real.
+ The mathematical constant *pi*, as a float.
.. data:: e
- The mathematical constant *e*, as a real.
+ The mathematical constant *e*, as a float.
.. index:: module: math
Modified: doctools/trunk/Doc-26/library/dbhash.rst
==============================================================================
--- doctools/trunk/Doc-26/library/dbhash.rst (original)
+++ doctools/trunk/Doc-26/library/dbhash.rst Mon Aug 13 22:52:56 2007
@@ -28,10 +28,26 @@
Open a ``db`` database and return the database object. The *path* argument is
the name of the database file.
- The *flag* argument can be ``'r'`` (the default), ``'w'``, ``'c'`` (which
- creates the database if it doesn't exist), or ``'n'`` (which always creates a
- new empty database). For platforms on which the BSD ``db`` library supports
- locking, an ``'l'`` can be appended to indicate that locking should be used.
+ The *flag* argument can be:
+
+ +---------+-------------------------------------------+
+ | Value | Meaning |
+ +=========+===========================================+
+ | ``'r'`` | Open existing database for reading only |
+ | | (default) |
+ +---------+-------------------------------------------+
+ | ``'w'`` | Open existing database for reading and |
+ | | writing |
+ +---------+-------------------------------------------+
+ | ``'c'`` | Open database for reading and writing, |
+ | | creating it if it doesn't exist |
+ +---------+-------------------------------------------+
+ | ``'n'`` | Always create a new, empty database, open |
+ | | for reading and writing |
+ +---------+-------------------------------------------+
+
+ For platforms on which the BSD ``db`` library supports locking, an ``'l'``
+ can be appended to indicate that locking should be used.
The optional *mode* parameter is used to indicate the Unix permission bits that
should be set if a new database must be created; this will be masked by the
Modified: doctools/trunk/Doc-26/library/dbm.rst
==============================================================================
--- doctools/trunk/Doc-26/library/dbm.rst (original)
+++ doctools/trunk/Doc-26/library/dbm.rst Mon Aug 13 22:52:56 2007
@@ -7,8 +7,8 @@
:synopsis: The standard "database" interface, based on ndbm.
-The :mod:`dbm` module provides an interface to the Unix (``n``)``dbm`` library.
-Dbm objects behave like mappings (dictionaries), except that keys and values are
+The :mod:`dbm` module provides an interface to the Unix "(n)dbm" library. Dbm
+objects behave like mappings (dictionaries), except that keys and values are
always strings. Printing a dbm object doesn't print the keys and values, and the
:meth:`items` and :meth:`values` methods are not supported.
@@ -57,7 +57,8 @@
+---------+-------------------------------------------+
The optional *mode* argument is the Unix mode of the file, used only when the
- database has to be created. It defaults to octal ``0666``.
+ database has to be created. It defaults to octal ``0666`` (and will be
+ modified by the prevailing umask).
.. seealso::
Modified: doctools/trunk/Doc-26/library/filecmp.rst
==============================================================================
--- doctools/trunk/Doc-26/library/filecmp.rst (original)
+++ doctools/trunk/Doc-26/library/filecmp.rst Mon Aug 13 22:52:56 2007
@@ -44,9 +44,9 @@
Example::
>>> import filecmp
- >>> filecmp.cmp('libundoc.tex', 'libundoc.tex')
+ >>> filecmp.cmp('undoc.rst', 'undoc.rst')
True
- >>> filecmp.cmp('libundoc.tex', 'lib.tex')
+ >>> filecmp.cmp('undoc.rst', 'index.rst')
False
Modified: doctools/trunk/Doc-26/library/fileinput.rst
==============================================================================
--- doctools/trunk/Doc-26/library/fileinput.rst (original)
+++ doctools/trunk/Doc-26/library/fileinput.rst Mon Aug 13 22:52:56 2007
@@ -34,14 +34,14 @@
the list of filenames is noticeable at all is when the last file opened is
empty.
-It is possible that the last line of a file does not end in a newline character;
-lines are returned including the trailing newline when it is present.
+Lines are returned with any newlines intact, which means that the last line in
+a file may not have one.
You can control how files are opened by providing an opening hook via the
-*openhook* parameter to :func:`input` or :class:`FileInput()`. The hook must be
-a function that takes two arguments, *filename* and *mode*, and returns an
-accordingly opened file-like object. Two useful hooks are already provided by
-this module.
+*openhook* parameter to :func:`fileinput.input` or :class:`FileInput()`. The
+hook must be a function that takes two arguments, *filename* and *mode*, and
+returns an accordingly opened file-like object. Two useful hooks are already
+provided by this module.
The following function is the primary interface of this module:
@@ -56,8 +56,8 @@
.. versionchanged:: 2.5
Added the *mode* and *openhook* parameters.
-The following functions use the global state created by :func:`input`; if there
-is no active state, :exc:`RuntimeError` is raised.
+The following functions use the global state created by :func:`fileinput.input`;
+if there is no active state, :exc:`RuntimeError` is raised.
.. function:: filename()
@@ -121,7 +121,7 @@
.. class:: FileInput([files[, inplace[, backup[, mode[, openhook]]]]])
Class :class:`FileInput` is the implementation; its methods :meth:`filename`,
- :meth:`fileno`, :meth:`lineno`, :meth:`fileline`, :meth:`isfirstline`,
+ :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`,
:meth:`isstdin`, :meth:`nextfile` and :meth:`close` correspond to the functions
of the same name in the module. In addition it has a :meth:`readline` method
which returns the next input line, and a :meth:`__getitem__` method which
@@ -139,14 +139,15 @@
Added the *mode* and *openhook* parameters.
**Optional in-place filtering:** if the keyword argument ``inplace=1`` is passed
-to :func:`input` or to the :class:`FileInput` constructor, the file is moved to
-a backup file and standard output is directed to the input file (if a file of
-the same name as the backup file already exists, it will be replaced silently).
-This makes it possible to write a filter that rewrites its input file in place.
-If the keyword argument ``backup='.<some extension>'`` is also given, it
-specifies the extension for the backup file, and the backup file remains around;
-by default, the extension is ``'.bak'`` and it is deleted when the output file
-is closed. In-place filtering is disabled when standard input is read.
+to :func:`fileinput.input` or to the :class:`FileInput` constructor, the file is
+moved to a backup file and standard output is directed to the input file (if a
+file of the same name as the backup file already exists, it will be replaced
+silently). This makes it possible to write a filter that rewrites its input
+file in place. If the *backup* parameter is given (typically as
+``backup='.<some extension>'``), it specifies the extension for the backup file,
+and the backup file remains around; by default, the extension is ``'.bak'`` and
+it is deleted when the output file is closed. In-place filtering is disabled
+when standard input is read.
**Caveat:** The current implementation does not work for MS-DOS 8+3 filesystems.
Modified: doctools/trunk/Doc-26/library/functools.rst
==============================================================================
--- doctools/trunk/Doc-26/library/functools.rst (original)
+++ doctools/trunk/Doc-26/library/functools.rst Mon Aug 13 22:52:56 2007
@@ -107,19 +107,19 @@
have three read-only attributes:
-.. attribute:: callable.func
+.. attribute:: partial.func
A callable object or function. Calls to the :class:`partial` object will be
forwarded to :attr:`func` with new arguments and keywords.
-.. attribute:: tuple.args
+.. attribute:: partial.args
The leftmost positional arguments that will be prepended to the positional
arguments provided to a :class:`partial` object call.
-.. attribute:: dict.keywords
+.. attribute:: partial.keywords
The keyword arguments that will be supplied when the :class:`partial` object is
called.
Modified: doctools/trunk/Doc-26/library/gdbm.rst
==============================================================================
--- doctools/trunk/Doc-26/library/gdbm.rst (original)
+++ doctools/trunk/Doc-26/library/gdbm.rst Mon Aug 13 22:52:56 2007
@@ -32,24 +32,42 @@
Open a ``gdbm`` database and return a ``gdbm`` object. The *filename* argument
is the name of the database file.
- The optional *flag* argument can be ``'r'`` (to open an existing database for
- reading only --- default), ``'w'`` (to open an existing database for reading and
- writing), ``'c'`` (which creates the database if it doesn't exist), or ``'n'``
- (which always creates a new empty database).
+ The optional *flag* argument can be:
- The following additional characters may be appended to the flag to control how
- the database is opened:
-
- * ``'f'`` --- Open the database in fast mode. Writes to the database will not
- be synchronized.
-
- * ``'s'`` --- Synchronized mode. This will cause changes to the database will be
- immediately written to the file.
-
- * ``'u'`` --- Do not lock database.
+ +---------+-------------------------------------------+
+ | Value | Meaning |
+ +=========+===========================================+
+ | ``'r'`` | Open existing database for reading only |
+ | | (default) |
+ +---------+-------------------------------------------+
+ | ``'w'`` | Open existing database for reading and |
+ | | writing |
+ +---------+-------------------------------------------+
+ | ``'c'`` | Open database for reading and writing, |
+ | | creating it if it doesn't exist |
+ +---------+-------------------------------------------+
+ | ``'n'`` | Always create a new, empty database, open |
+ | | for reading and writing |
+ +---------+-------------------------------------------+
+
+ The following additional characters may be appended to the flag to control
+ how the database is opened:
+
+ +---------+--------------------------------------------+
+ | Value | Meaning |
+ +=========+============================================+
+ | ``'f'`` | Open the database in fast mode. Writes |
+ | | to the database will not be synchronized. |
+ +---------+--------------------------------------------+
+ | ``'s'`` | Synchronized mode. This will cause changes |
+ | | to the database to be immediately written |
+ | | to the file. |
+ +---------+--------------------------------------------+
+ | ``'u'`` | Do not lock database. |
+ +---------+--------------------------------------------+
Not all flags are valid for all versions of ``gdbm``. The module constant
- ``open_flags`` is a string of supported flag characters. The exception
+ :const:`open_flags` is a string of supported flag characters. The exception
:exc:`error` is raised if an invalid flag is specified.
The optional *mode* argument is the Unix mode of the file, used only when the
Modified: doctools/trunk/Doc-26/library/itertools.rst
==============================================================================
--- doctools/trunk/Doc-26/library/itertools.rst (original)
+++ doctools/trunk/Doc-26/library/itertools.rst Mon Aug 13 22:52:56 2007
@@ -311,7 +311,7 @@
If one of the iterables is potentially infinite, then the :func:`izip_longest`
function should be wrapped with something that limits the number of calls (for
- example :func:`islice` or :func:`take`).
+ example :func:`islice` or :func:`takewhile`).
.. versionadded:: 2.6
@@ -414,7 +414,7 @@
64
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura',
- '', 'martin', '', 'walter', '', 'mark']
+ ... '', 'martin', '', 'walter', '', 'mark']
>>> for name in islice(reportlines, 3, None, 2):
... print name.title()
...
Modified: doctools/trunk/Doc-26/library/marshal.rst
==============================================================================
--- doctools/trunk/Doc-26/library/marshal.rst (original)
+++ doctools/trunk/Doc-26/library/marshal.rst Mon Aug 13 22:52:56 2007
@@ -30,8 +30,8 @@
.. warning::
The :mod:`marshal` module is not intended to be secure against erroneous or
- maliciously constructed data. Never unmarshal data received from an untrusted
- or unauthenticated source.
+ maliciously constructed data. Never unmarshal data received from an
+ untrusted or unauthenticated source.
Not all Python object types are supported; in general, only objects whose value
is independent from a particular invocation of Python can be written and read by
@@ -59,25 +59,27 @@
.. function:: dump(value, file[, version])
- Write the value on the open file. The value must be a supported type. The file
- must be an open file object such as ``sys.stdout`` or returned by :func:`open`
- or :func:`posix.popen`. It must be opened in binary mode (``'wb'`` or
- ``'w+b'``).
+ Write the value on the open file. The value must be a supported type. The
+ file must be an open file object such as ``sys.stdout`` or returned by
+ :func:`open` or :func:`os.popen`. It must be opened in binary mode (``'wb'``
+ or ``'w+b'``).
If the value has (or contains an object that has) an unsupported type, a
:exc:`ValueError` exception is raised --- but garbage data will also be written
to the file. The object will not be properly read back by :func:`load`.
.. versionadded:: 2.4
- The *version* argument indicates the data format that ``dump`` should use (see
- below).
+ The *version* argument indicates the data format that ``dump`` should use
+ (see below).
.. function:: load(file)
- Read one value from the open file and return it. If no valid value is read,
- raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The file must be
- an open file object opened in binary mode (``'rb'`` or ``'r+b'``).
+ Read one value from the open file and return it. If no valid value is read
+ (e.g. because the data has a different Python version's incompatible marshal
+ format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The
+ file must be an open file object opened in binary mode (``'rb'`` or
+ ``'r+b'``).
.. warning::
@@ -92,8 +94,8 @@
has (or contains an object that has) an unsupported type.
.. versionadded:: 2.4
- The *version* argument indicates the data format that ``dumps`` should use (see
- below).
+ The *version* argument indicates the data format that ``dumps`` should use
+ (see below).
.. function:: loads(string)
@@ -102,8 +104,8 @@
:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. Extra characters in the
string are ignored.
-In addition, the following constants are defined:
+In addition, the following constants are defined:
.. data:: version
@@ -114,6 +116,7 @@
.. versionadded:: 2.4
+
.. rubric:: Footnotes
.. [#] The name of this module stems from a bit of terminology used by the designers of
Modified: doctools/trunk/Doc-26/library/operator.rst
==============================================================================
--- doctools/trunk/Doc-26/library/operator.rst (original)
+++ doctools/trunk/Doc-26/library/operator.rst Mon Aug 13 22:52:56 2007
@@ -118,7 +118,9 @@
__invert__(o)
Return the bitwise inverse of the number *o*. This is equivalent to ``~o``.
- The names :func:`invert` and :func:`__invert__` were added in Python 2.0.
+
+ .. versionadded:: 2.0
+ The names :func:`invert` and :func:`__invert__`.
.. function:: lshift(a, b)
@@ -199,8 +201,8 @@
.. versionadded:: 2.5
-Operations which work with sequences include:
+Operations which work with sequences include:
.. function:: concat(a, b)
__concat__(a, b)
@@ -211,8 +213,10 @@
.. function:: contains(a, b)
__contains__(a, b)
- Return the outcome of the test ``b in a``. Note the reversed operands. The
- name :func:`__contains__` was added in Python 2.0.
+ Return the outcome of the test ``b in a``. Note the reversed operands.
+
+ .. versionadded:: 2.0
+ The name :func:`__contains__`.
.. function:: countOf(a, b)
@@ -477,6 +481,8 @@
>>> vals = map(chr, keys)
>>> map(operator.setitem, [d]*len(keys), keys, vals)
+.. XXX: find a better, readable, example
+
The :mod:`operator` module also defines tools for generalized attribute and item
lookups. These are useful for making fast field extractors as arguments for
:func:`map`, :func:`sorted`, :meth:`itertools.groupby`, or other functions that
@@ -537,11 +543,11 @@
+-----------------------+-------------------------+---------------------------------+
| Containment Test | ``o in seq`` | ``contains(seq, o)`` |
+-----------------------+-------------------------+---------------------------------+
-| Division | ``a / b`` | ``div(a, b) #`` without |
-| | | ``__future__.division`` |
+| Division | ``a / b`` | ``div(a, b)`` (without |
+| | | ``__future__.division``) |
+-----------------------+-------------------------+---------------------------------+
-| Division | ``a / b`` | ``truediv(a, b) #`` with |
-| | | ``__future__.division`` |
+| Division | ``a / b`` | ``truediv(a, b)`` (with |
+| | | ``__future__.division``) |
+-----------------------+-------------------------+---------------------------------+
| Division | ``a // b`` | ``floordiv(a, b)`` |
+-----------------------+-------------------------+---------------------------------+
@@ -579,7 +585,7 @@
+-----------------------+-------------------------+---------------------------------+
| Sequence Repitition | ``seq * i`` | ``repeat(seq, i)`` |
+-----------------------+-------------------------+---------------------------------+
-| Slice Assignment | ``seq[i:j]`` = *values* | ``setslice(seq, i, j, values)`` |
+| Slice Assignment | ``seq[i:j] = values`` | ``setslice(seq, i, j, values)`` |
+-----------------------+-------------------------+---------------------------------+
| Slice Deletion | ``del seq[i:j]`` | ``delslice(seq, i, j)`` |
+-----------------------+-------------------------+---------------------------------+
Modified: doctools/trunk/Doc-26/library/os.path.rst
==============================================================================
--- doctools/trunk/Doc-26/library/os.path.rst (original)
+++ doctools/trunk/Doc-26/library/os.path.rst Mon Aug 13 22:52:56 2007
@@ -182,7 +182,7 @@
the concatenation of *path1*, and optionally *path2*, etc., with exactly one
directory separator (``os.sep``) inserted between components, unless *path2* is
empty. Note that on Windows, since there is a current directory for each drive,
- :func:`os.path.join("c:", "foo")` represents a path relative to the current
+ ``os.path.join("c:", "foo")`` represents a path relative to the current
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
@@ -267,12 +267,12 @@
Split the pathname *path* into a pair ``(root, ext)`` such that ``root + ext ==
path``, and *ext* is empty or begins with a period and contains at most one
- period. Leading periods on the basename are ignored; ``splitext.('.cshrc')``
+ period. Leading periods on the basename are ignored; ``splitext('.cshrc')``
returns ``('.cshrc', '')``.
.. versionchanged:: 2.6
- Earlier versions could produce an empty root when the only period was the first
- character.
+ Earlier versions could produce an empty root when the only period was the
+ first character.
.. function:: splitunc(path)
Modified: doctools/trunk/Doc-26/library/pickle.rst
==============================================================================
--- doctools/trunk/Doc-26/library/pickle.rst (original)
+++ doctools/trunk/Doc-26/library/pickle.rst Mon Aug 13 22:52:56 2007
@@ -124,7 +124,7 @@
* Protocol version 2 was introduced in Python 2.3. It provides much more
efficient pickling of new-style classes.
-Refer to PEP 307 for more information.
+Refer to :pep:`307` for more information.
If a *protocol* is not specified, protocol 0 is used. If *protocol* is specified
as a negative value or :const:`HIGHEST_PROTOCOL`, the highest protocol version
@@ -249,7 +249,8 @@
This takes a file-like object to which it will write a pickle data stream.
If the *protocol* parameter is omitted, protocol 0 is used. If *protocol* is
- specified as a negative value, the highest protocol version will be used.
+ specified as a negative value or :const:`HIGHEST_PROTOCOL`, the highest
+ protocol version will be used.
.. versionchanged:: 2.3
Introduced the *protocol* parameter.
@@ -317,6 +318,9 @@
Read a pickled object representation from the open file object given in the
constructor, and return the reconstituted object hierarchy specified therein.
+ This method automatically determines whether the data stream was written in
+ binary mode or not.
+
.. method:: Unpickler.noload()
@@ -713,6 +717,8 @@
reading resumes from the last location. The :meth:`__setstate__` and
:meth:`__getstate__` methods are used to implement this behavior. ::
+ #!/usr/local/bin/python
+
class TextReader:
"""Print and number lines in a text file."""
def __init__(self, file):
@@ -749,11 +755,12 @@
>>> obj = TextReader.TextReader("TextReader.py")
>>> obj.readline()
'1: #!/usr/local/bin/python'
- >>> # (more invocations of obj.readline() here)
- ... obj.readline()
- '7: class TextReader:'
+ >>> obj.readline()
+ '2: '
+ >>> obj.readline()
+ '3: class TextReader:'
>>> import pickle
- >>> pickle.dump(obj,open('save.p', 'wb'))
+ >>> pickle.dump(obj, open('save.p', 'wb'))
If you want to see that :mod:`pickle` works across Python processes, start
another Python session, before continuing. What follows can happen from either
@@ -762,7 +769,7 @@
>>> import pickle
>>> reader = pickle.load(open('save.p', 'rb'))
>>> reader.readline()
- '8: "Print and number lines in a text file."'
+ '4: """Print and number lines in a text file."""'
.. seealso::
Modified: doctools/trunk/Doc-26/library/random.rst
==============================================================================
--- doctools/trunk/Doc-26/library/random.rst (original)
+++ doctools/trunk/Doc-26/library/random.rst Mon Aug 13 22:52:56 2007
@@ -103,7 +103,7 @@
.. versionadded:: 2.1
.. versionchanged:: 2.3
- Instead of jumping to a specific state, *n* steps ahead, :meth:`jumpahead(n)`
+ Instead of jumping to a specific state, *n* steps ahead, ``jumpahead(n)``
jumps to another state likely to be separated by many steps.
@@ -185,7 +185,7 @@
.. function:: uniform(a, b)
- Return a random real number *N* such that ``a <= N < b``.
+ Return a random floating point number *N* such that ``a <= N < b``.
.. function:: betavariate(alpha, beta)
@@ -228,10 +228,10 @@
.. function:: vonmisesvariate(mu, kappa)
- *mu* is the mean angle, expressed in radians between 0 and 2\**pi*, and *kappa*
+ *mu* is the mean angle, expressed in radians between 0 and 2\*\ *pi*, and *kappa*
is the concentration parameter, which must be greater than or equal to zero. If
*kappa* is equal to zero, this distribution reduces to a uniform random angle
- over the range 0 to 2\**pi*.
+ over the range 0 to 2\*\ *pi*.
.. function:: paretovariate(alpha)
@@ -244,8 +244,8 @@
Weibull distribution. *alpha* is the scale parameter and *beta* is the shape
parameter.
-Alternative Generators:
+Alternative Generators:
.. class:: WichmannHill([seed])
Modified: doctools/trunk/Doc-26/library/shutil.rst
==============================================================================
--- doctools/trunk/Doc-26/library/shutil.rst (original)
+++ doctools/trunk/Doc-26/library/shutil.rst Mon Aug 13 22:52:56 2007
@@ -66,7 +66,7 @@
.. function:: copy2(src, dst)
Similar to :func:`copy`, but last access time and last modification time are
- copied as well. This is similar to the Unix command :program:`cp` :option:`-p`.
+ copied as well. This is similar to the Unix command :program:`cp -p`.
.. function:: copytree(src, dst[, symlinks])
@@ -137,9 +137,10 @@
above, with the docstring omitted. It demonstrates many of the other functions
provided by this module. ::
- def copytree(src, dst, symlinks=0):
+ def copytree(src, dst, symlinks=False):
names = os.listdir(src)
- os.mkdir(dst)
+ os.makedirs(dst)
+ errors = []
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
@@ -151,6 +152,19 @@
copytree(srcname, dstname, symlinks)
else:
copy2(srcname, dstname)
+ # XXX What about devices, sockets etc.?
except (IOError, os.error), why:
- print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))
-
+ errors.append((srcname, dstname, str(why)))
+ # catch the Error from the recursive copytree so that we can
+ # continue with other files
+ except Error, err:
+ errors.extend(err.args[0])
+ try:
+ copystat(src, dst)
+ except WindowsError:
+ # can't copy file access times on Windows
+ pass
+ except OSError, why:
+ errors.extend((src, dst, str(why)))
+ if errors:
+ raise Error, errors
Modified: doctools/trunk/Doc-26/library/tempfile.rst
==============================================================================
--- doctools/trunk/Doc-26/library/tempfile.rst (original)
+++ doctools/trunk/Doc-26/library/tempfile.rst Mon Aug 13 22:52:56 2007
@@ -81,12 +81,13 @@
.. function:: mkstemp([suffix[, prefix[, dir[, text]]]])
- Creates a temporary file in the most secure manner possible. There are no race
- conditions in the file's creation, assuming that the platform properly
- implements the :const:`O_EXCL` flag for :func:`os.open`. The file is readable
- and writable only by the creating user ID. If the platform uses permission bits
- to indicate whether a file is executable, the file is executable by no one. The
- file descriptor is not inherited by child processes.
+ Creates a temporary file in the most secure manner possible. There are no
+ race conditions in the file's creation, assuming that the platform properly
+ implements the :const:`os.O_EXCL` flag for :func:`os.open`. The file is
+ readable and writable only by the creating user ID. If the platform uses
+ permission bits to indicate whether a file is executable, the file is
+ executable by no one. The file descriptor is not inherited by child
+ processes.
Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible for
deleting the temporary file when done with it.
@@ -173,7 +174,7 @@
* On RiscOS, the directory named by the :envvar:`Wimp$ScrapDir` environment
variable.
- * On Windows, the directories :file:`C:$\\TEMP`, :file:`C:$\\TMP`,
+ * On Windows, the directories :file:`C:\\TEMP`, :file:`C:\\TMP`,
:file:`\\TEMP`, and :file:`\\TMP`, in that order.
* On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and
@@ -185,8 +186,8 @@
.. function:: gettempdir()
Return the directory currently selected to create temporary files in. If
- ``tempdir`` is not ``None``, this simply returns its contents; otherwise, the
- search described above is performed, and the result returned.
+ :data:`tempdir` is not ``None``, this simply returns its contents; otherwise,
+ the search described above is performed, and the result returned.
.. data:: template
Modified: doctools/trunk/Doc-3k/library/anydbm.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/anydbm.rst (original)
+++ doctools/trunk/Doc-3k/library/anydbm.rst Mon Aug 13 22:52:56 2007
@@ -41,8 +41,8 @@
.. exception:: error
A tuple containing the exceptions that can be raised by each of the supported
- modules, with a unique exception :exc:`anydbm.error` as the first item --- the
- latter is used when :exc:`anydbm.error` is raised.
+ modules, with a unique exception also named :exc:`anydbm.error` as the first
+ item --- the latter is used when :exc:`anydbm.error` is raised.
The object returned by :func:`open` supports most of the same functionality as
dictionaries; keys and their corresponding values can be stored, retrieved, and
Modified: doctools/trunk/Doc-3k/library/cmath.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/cmath.rst (original)
+++ doctools/trunk/Doc-3k/library/cmath.rst Mon Aug 13 22:52:56 2007
@@ -37,29 +37,30 @@
.. function:: asinh(x)
- Return the hyperbolic arc sine of *x*. There are two branch cuts, extending left
- from ±``1j`` to ±-∞``j``, both continuous from above. These branch cuts should
- be considered a bug to be corrected in a future release. The correct branch cuts
- should extend along the imaginary axis, one from ``1j`` up to ∞``j`` and
- continuous from the right, and one from -\ ``1j`` down to -∞``j`` and continuous
- from the left.
+ Return the hyperbolic arc sine of *x*. There are two branch cuts, extending
+ left from ``±1j`` to ``±∞j``, both continuous from above. These branch cuts
+ should be considered a bug to be corrected in a future release. The correct
+ branch cuts should extend along the imaginary axis, one from ``1j`` up to
+ ``∞j`` and continuous from the right, and one from ``-1j`` down to ``-∞j``
+ and continuous from the left.
.. function:: atan(x)
Return the arc tangent of *x*. There are two branch cuts: One extends from
- ``1j`` along the imaginary axis to ∞``j``, continuous from the left. The other
- extends from -\ ``1j`` along the imaginary axis to -∞``j``, continuous from the
- left. (This should probably be changed so the upper cut becomes continuous from
- the other side.)
+ ``1j`` along the imaginary axis to ``∞j``, continuous from the left. The
+ other extends from ``-1j`` along the imaginary axis to ``-∞j``, continuous
+ from the left. (This should probably be changed so the upper cut becomes
+ continuous from the other side.)
.. function:: atanh(x)
- Return the hyperbolic arc tangent of *x*. There are two branch cuts: One extends
- from 1 along the real axis to ∞, continuous from above. The other extends from
- -1 along the real axis to -∞, continuous from above. (This should probably be
- changed so the right cut becomes continuous from the other side.)
+ Return the hyperbolic arc tangent of *x*. There are two branch cuts: One
+ extends from ``1`` along the real axis to ``∞``, continuous from above. The
+ other extends from ``-1`` along the real axis to ``-∞``, continuous from
+ above. (This should probably be changed so the right cut becomes continuous
+ from the other side.)
.. function:: cos(x)
@@ -122,12 +123,12 @@
.. data:: pi
- The mathematical constant *pi*, as a real.
+ The mathematical constant *pi*, as a float.
.. data:: e
- The mathematical constant *e*, as a real.
+ The mathematical constant *e*, as a float.
.. index:: module: math
Modified: doctools/trunk/Doc-3k/library/dbhash.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/dbhash.rst (original)
+++ doctools/trunk/Doc-3k/library/dbhash.rst Mon Aug 13 22:52:56 2007
@@ -28,10 +28,26 @@
Open a ``db`` database and return the database object. The *path* argument is
the name of the database file.
- The *flag* argument can be ``'r'`` (the default), ``'w'``, ``'c'`` (which
- creates the database if it doesn't exist), or ``'n'`` (which always creates a
- new empty database). For platforms on which the BSD ``db`` library supports
- locking, an ``'l'`` can be appended to indicate that locking should be used.
+ The *flag* argument can be:
+
+ +---------+-------------------------------------------+
+ | Value | Meaning |
+ +=========+===========================================+
+ | ``'r'`` | Open existing database for reading only |
+ | | (default) |
+ +---------+-------------------------------------------+
+ | ``'w'`` | Open existing database for reading and |
+ | | writing |
+ +---------+-------------------------------------------+
+ | ``'c'`` | Open database for reading and writing, |
+ | | creating it if it doesn't exist |
+ +---------+-------------------------------------------+
+ | ``'n'`` | Always create a new, empty database, open |
+ | | for reading and writing |
+ +---------+-------------------------------------------+
+
+ For platforms on which the BSD ``db`` library supports locking, an ``'l'``
+ can be appended to indicate that locking should be used.
The optional *mode* parameter is used to indicate the Unix permission bits that
should be set if a new database must be created; this will be masked by the
Modified: doctools/trunk/Doc-3k/library/dbm.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/dbm.rst (original)
+++ doctools/trunk/Doc-3k/library/dbm.rst Mon Aug 13 22:52:56 2007
@@ -7,8 +7,8 @@
:synopsis: The standard "database" interface, based on ndbm.
-The :mod:`dbm` module provides an interface to the Unix (``n``)``dbm`` library.
-Dbm objects behave like mappings (dictionaries), except that keys and values are
+The :mod:`dbm` module provides an interface to the Unix "(n)dbm" library. Dbm
+objects behave like mappings (dictionaries), except that keys and values are
always strings. Printing a dbm object doesn't print the keys and values, and the
:meth:`items` and :meth:`values` methods are not supported.
@@ -57,7 +57,8 @@
+---------+-------------------------------------------+
The optional *mode* argument is the Unix mode of the file, used only when the
- database has to be created. It defaults to octal ``0666``.
+ database has to be created. It defaults to octal ``0666`` (and will be
+ modified by the prevailing umask).
.. seealso::
Modified: doctools/trunk/Doc-3k/library/filecmp.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/filecmp.rst (original)
+++ doctools/trunk/Doc-3k/library/filecmp.rst Mon Aug 13 22:52:56 2007
@@ -44,9 +44,9 @@
Example::
>>> import filecmp
- >>> filecmp.cmp('libundoc.tex', 'libundoc.tex')
+ >>> filecmp.cmp('undoc.rst', 'undoc.rst')
True
- >>> filecmp.cmp('libundoc.tex', 'lib.tex')
+ >>> filecmp.cmp('undoc.rst', 'index.rst')
False
Modified: doctools/trunk/Doc-3k/library/fileinput.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/fileinput.rst (original)
+++ doctools/trunk/Doc-3k/library/fileinput.rst Mon Aug 13 22:52:56 2007
@@ -34,14 +34,14 @@
the list of filenames is noticeable at all is when the last file opened is
empty.
-It is possible that the last line of a file does not end in a newline character;
-lines are returned including the trailing newline when it is present.
+Lines are returned with any newlines intact, which means that the last line in
+a file may not have one.
You can control how files are opened by providing an opening hook via the
-*openhook* parameter to :func:`input` or :class:`FileInput()`. The hook must be
-a function that takes two arguments, *filename* and *mode*, and returns an
-accordingly opened file-like object. Two useful hooks are already provided by
-this module.
+*openhook* parameter to :func:`fileinput.input` or :class:`FileInput()`. The
+hook must be a function that takes two arguments, *filename* and *mode*, and
+returns an accordingly opened file-like object. Two useful hooks are already
+provided by this module.
The following function is the primary interface of this module:
@@ -56,8 +56,8 @@
.. versionchanged:: 2.5
Added the *mode* and *openhook* parameters.
-The following functions use the global state created by :func:`input`; if there
-is no active state, :exc:`RuntimeError` is raised.
+The following functions use the global state created by :func:`fileinput.input`;
+if there is no active state, :exc:`RuntimeError` is raised.
.. function:: filename()
@@ -121,7 +121,7 @@
.. class:: FileInput([files[, inplace[, backup[, mode[, openhook]]]]])
Class :class:`FileInput` is the implementation; its methods :meth:`filename`,
- :meth:`fileno`, :meth:`lineno`, :meth:`fileline`, :meth:`isfirstline`,
+ :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`,
:meth:`isstdin`, :meth:`nextfile` and :meth:`close` correspond to the functions
of the same name in the module. In addition it has a :meth:`readline` method
which returns the next input line, and a :meth:`__getitem__` method which
@@ -139,14 +139,15 @@
Added the *mode* and *openhook* parameters.
**Optional in-place filtering:** if the keyword argument ``inplace=1`` is passed
-to :func:`input` or to the :class:`FileInput` constructor, the file is moved to
-a backup file and standard output is directed to the input file (if a file of
-the same name as the backup file already exists, it will be replaced silently).
-This makes it possible to write a filter that rewrites its input file in place.
-If the keyword argument ``backup='.<some extension>'`` is also given, it
-specifies the extension for the backup file, and the backup file remains around;
-by default, the extension is ``'.bak'`` and it is deleted when the output file
-is closed. In-place filtering is disabled when standard input is read.
+to :func:`fileinput.input` or to the :class:`FileInput` constructor, the file is
+moved to a backup file and standard output is directed to the input file (if a
+file of the same name as the backup file already exists, it will be replaced
+silently). This makes it possible to write a filter that rewrites its input
+file in place. If the *backup* parameter is given (typically as
+``backup='.<some extension>'``), it specifies the extension for the backup file,
+and the backup file remains around; by default, the extension is ``'.bak'`` and
+it is deleted when the output file is closed. In-place filtering is disabled
+when standard input is read.
**Caveat:** The current implementation does not work for MS-DOS 8+3 filesystems.
Modified: doctools/trunk/Doc-3k/library/functools.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/functools.rst (original)
+++ doctools/trunk/Doc-3k/library/functools.rst Mon Aug 13 22:52:56 2007
@@ -119,19 +119,19 @@
have three read-only attributes:
-.. attribute:: callable.func
+.. attribute:: partial.func
A callable object or function. Calls to the :class:`partial` object will be
forwarded to :attr:`func` with new arguments and keywords.
-.. attribute:: tuple.args
+.. attribute:: partial.args
The leftmost positional arguments that will be prepended to the positional
arguments provided to a :class:`partial` object call.
-.. attribute:: dict.keywords
+.. attribute:: partial.keywords
The keyword arguments that will be supplied when the :class:`partial` object is
called.
Modified: doctools/trunk/Doc-3k/library/gdbm.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/gdbm.rst (original)
+++ doctools/trunk/Doc-3k/library/gdbm.rst Mon Aug 13 22:52:56 2007
@@ -32,24 +32,42 @@
Open a ``gdbm`` database and return a ``gdbm`` object. The *filename* argument
is the name of the database file.
- The optional *flag* argument can be ``'r'`` (to open an existing database for
- reading only --- default), ``'w'`` (to open an existing database for reading and
- writing), ``'c'`` (which creates the database if it doesn't exist), or ``'n'``
- (which always creates a new empty database).
+ The optional *flag* argument can be:
- The following additional characters may be appended to the flag to control how
- the database is opened:
-
- * ``'f'`` --- Open the database in fast mode. Writes to the database will not
- be synchronized.
-
- * ``'s'`` --- Synchronized mode. This will cause changes to the database will be
- immediately written to the file.
-
- * ``'u'`` --- Do not lock database.
+ +---------+-------------------------------------------+
+ | Value | Meaning |
+ +=========+===========================================+
+ | ``'r'`` | Open existing database for reading only |
+ | | (default) |
+ +---------+-------------------------------------------+
+ | ``'w'`` | Open existing database for reading and |
+ | | writing |
+ +---------+-------------------------------------------+
+ | ``'c'`` | Open database for reading and writing, |
+ | | creating it if it doesn't exist |
+ +---------+-------------------------------------------+
+ | ``'n'`` | Always create a new, empty database, open |
+ | | for reading and writing |
+ +---------+-------------------------------------------+
+
+ The following additional characters may be appended to the flag to control
+ how the database is opened:
+
+ +---------+--------------------------------------------+
+ | Value | Meaning |
+ +=========+============================================+
+ | ``'f'`` | Open the database in fast mode. Writes |
+ | | to the database will not be synchronized. |
+ +---------+--------------------------------------------+
+ | ``'s'`` | Synchronized mode. This will cause changes |
+ | | to the database to be immediately written |
+ | | to the file. |
+ +---------+--------------------------------------------+
+ | ``'u'`` | Do not lock database. |
+ +---------+--------------------------------------------+
Not all flags are valid for all versions of ``gdbm``. The module constant
- ``open_flags`` is a string of supported flag characters. The exception
+ :const:`open_flags` is a string of supported flag characters. The exception
:exc:`error` is raised if an invalid flag is specified.
The optional *mode* argument is the Unix mode of the file, used only when the
Modified: doctools/trunk/Doc-3k/library/itertools.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/itertools.rst (original)
+++ doctools/trunk/Doc-3k/library/itertools.rst Mon Aug 13 22:52:56 2007
@@ -311,7 +311,7 @@
If one of the iterables is potentially infinite, then the :func:`izip_longest`
function should be wrapped with something that limits the number of calls (for
- example :func:`islice` or :func:`take`).
+ example :func:`islice` or :func:`takewhile`).
.. versionadded:: 2.6
@@ -414,7 +414,7 @@
64
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura',
- '', 'martin', '', 'walter', '', 'mark']
+ ... '', 'martin', '', 'walter', '', 'mark']
>>> for name in islice(reportlines, 3, None, 2):
... print name.title()
...
Modified: doctools/trunk/Doc-3k/library/marshal.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/marshal.rst (original)
+++ doctools/trunk/Doc-3k/library/marshal.rst Mon Aug 13 22:52:56 2007
@@ -30,8 +30,8 @@
.. warning::
The :mod:`marshal` module is not intended to be secure against erroneous or
- maliciously constructed data. Never unmarshal data received from an untrusted
- or unauthenticated source.
+ maliciously constructed data. Never unmarshal data received from an
+ untrusted or unauthenticated source.
Not all Python object types are supported; in general, only objects whose value
is independent from a particular invocation of Python can be written and read by
@@ -59,25 +59,27 @@
.. function:: dump(value, file[, version])
- Write the value on the open file. The value must be a supported type. The file
- must be an open file object such as ``sys.stdout`` or returned by :func:`open`
- or :func:`posix.popen`. It must be opened in binary mode (``'wb'`` or
- ``'w+b'``).
+ Write the value on the open file. The value must be a supported type. The
+ file must be an open file object such as ``sys.stdout`` or returned by
+ :func:`open` or :func:`os.popen`. It must be opened in binary mode (``'wb'``
+ or ``'w+b'``).
If the value has (or contains an object that has) an unsupported type, a
:exc:`ValueError` exception is raised --- but garbage data will also be written
to the file. The object will not be properly read back by :func:`load`.
.. versionadded:: 2.4
- The *version* argument indicates the data format that ``dump`` should use (see
- below).
+ The *version* argument indicates the data format that ``dump`` should use
+ (see below).
.. function:: load(file)
- Read one value from the open file and return it. If no valid value is read,
- raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The file must be
- an open file object opened in binary mode (``'rb'`` or ``'r+b'``).
+ Read one value from the open file and return it. If no valid value is read
+ (e.g. because the data has a different Python version's incompatible marshal
+ format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The
+ file must be an open file object opened in binary mode (``'rb'`` or
+ ``'r+b'``).
.. warning::
@@ -92,8 +94,8 @@
has (or contains an object that has) an unsupported type.
.. versionadded:: 2.4
- The *version* argument indicates the data format that ``dumps`` should use (see
- below).
+ The *version* argument indicates the data format that ``dumps`` should use
+ (see below).
.. function:: loads(string)
@@ -102,8 +104,8 @@
:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. Extra characters in the
string are ignored.
-In addition, the following constants are defined:
+In addition, the following constants are defined:
.. data:: version
@@ -114,6 +116,7 @@
.. versionadded:: 2.4
+
.. rubric:: Footnotes
.. [#] The name of this module stems from a bit of terminology used by the designers of
Modified: doctools/trunk/Doc-3k/library/operator.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/operator.rst (original)
+++ doctools/trunk/Doc-3k/library/operator.rst Mon Aug 13 22:52:56 2007
@@ -118,7 +118,9 @@
__invert__(o)
Return the bitwise inverse of the number *o*. This is equivalent to ``~o``.
- The names :func:`invert` and :func:`__invert__` were added in Python 2.0.
+
+ .. versionadded:: 2.0
+ The names :func:`invert` and :func:`__invert__`.
.. function:: lshift(a, b)
@@ -199,8 +201,8 @@
.. versionadded:: 2.5
-Operations which work with sequences include:
+Operations which work with sequences include:
.. function:: concat(a, b)
__concat__(a, b)
@@ -211,8 +213,10 @@
.. function:: contains(a, b)
__contains__(a, b)
- Return the outcome of the test ``b in a``. Note the reversed operands. The
- name :func:`__contains__` was added in Python 2.0.
+ Return the outcome of the test ``b in a``. Note the reversed operands.
+
+ .. versionadded:: 2.0
+ The name :func:`__contains__`.
.. function:: countOf(a, b)
@@ -477,6 +481,8 @@
>>> vals = map(chr, keys)
>>> map(operator.setitem, [d]*len(keys), keys, vals)
+.. XXX: find a better, readable, example
+
The :mod:`operator` module also defines tools for generalized attribute and item
lookups. These are useful for making fast field extractors as arguments for
:func:`map`, :func:`sorted`, :meth:`itertools.groupby`, or other functions that
@@ -537,11 +543,11 @@
+-----------------------+-------------------------+---------------------------------+
| Containment Test | ``o in seq`` | ``contains(seq, o)`` |
+-----------------------+-------------------------+---------------------------------+
-| Division | ``a / b`` | ``div(a, b) #`` without |
-| | | ``__future__.division`` |
+| Division | ``a / b`` | ``div(a, b)`` (without |
+| | | ``__future__.division``) |
+-----------------------+-------------------------+---------------------------------+
-| Division | ``a / b`` | ``truediv(a, b) #`` with |
-| | | ``__future__.division`` |
+| Division | ``a / b`` | ``truediv(a, b)`` (with |
+| | | ``__future__.division``) |
+-----------------------+-------------------------+---------------------------------+
| Division | ``a // b`` | ``floordiv(a, b)`` |
+-----------------------+-------------------------+---------------------------------+
@@ -579,7 +585,7 @@
+-----------------------+-------------------------+---------------------------------+
| Sequence Repitition | ``seq * i`` | ``repeat(seq, i)`` |
+-----------------------+-------------------------+---------------------------------+
-| Slice Assignment | ``seq[i:j]`` = *values* | ``setslice(seq, i, j, values)`` |
+| Slice Assignment | ``seq[i:j] = values`` | ``setslice(seq, i, j, values)`` |
+-----------------------+-------------------------+---------------------------------+
| Slice Deletion | ``del seq[i:j]`` | ``delslice(seq, i, j)`` |
+-----------------------+-------------------------+---------------------------------+
Modified: doctools/trunk/Doc-3k/library/os.path.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/os.path.rst (original)
+++ doctools/trunk/Doc-3k/library/os.path.rst Mon Aug 13 22:52:56 2007
@@ -182,7 +182,7 @@
the concatenation of *path1*, and optionally *path2*, etc., with exactly one
directory separator (``os.sep``) inserted between components, unless *path2* is
empty. Note that on Windows, since there is a current directory for each drive,
- :func:`os.path.join("c:", "foo")` represents a path relative to the current
+ ``os.path.join("c:", "foo")`` represents a path relative to the current
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
@@ -267,12 +267,12 @@
Split the pathname *path* into a pair ``(root, ext)`` such that ``root + ext ==
path``, and *ext* is empty or begins with a period and contains at most one
- period. Leading periods on the basename are ignored; ``splitext.('.cshrc')``
+ period. Leading periods on the basename are ignored; ``splitext('.cshrc')``
returns ``('.cshrc', '')``.
.. versionchanged:: 2.6
- Earlier versions could produce an empty root when the only period was the first
- character.
+ Earlier versions could produce an empty root when the only period was the
+ first character.
.. function:: splitunc(path)
Modified: doctools/trunk/Doc-3k/library/pickle.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/pickle.rst (original)
+++ doctools/trunk/Doc-3k/library/pickle.rst Mon Aug 13 22:52:56 2007
@@ -124,7 +124,7 @@
* Protocol version 2 was introduced in Python 2.3. It provides much more
efficient pickling of new-style classes.
-Refer to PEP 307 for more information.
+Refer to :pep:`307` for more information.
If a *protocol* is not specified, protocol 0 is used. If *protocol* is specified
as a negative value or :const:`HIGHEST_PROTOCOL`, the highest protocol version
@@ -249,7 +249,8 @@
This takes a file-like object to which it will write a pickle data stream.
If the *protocol* parameter is omitted, protocol 0 is used. If *protocol* is
- specified as a negative value, the highest protocol version will be used.
+ specified as a negative value or :const:`HIGHEST_PROTOCOL`, the highest
+ protocol version will be used.
.. versionchanged:: 2.3
Introduced the *protocol* parameter.
@@ -317,6 +318,9 @@
Read a pickled object representation from the open file object given in the
constructor, and return the reconstituted object hierarchy specified therein.
+ This method automatically determines whether the data stream was written in
+ binary mode or not.
+
.. method:: Unpickler.noload()
@@ -713,6 +717,8 @@
reading resumes from the last location. The :meth:`__setstate__` and
:meth:`__getstate__` methods are used to implement this behavior. ::
+ #!/usr/local/bin/python
+
class TextReader:
"""Print and number lines in a text file."""
def __init__(self, file):
@@ -749,11 +755,12 @@
>>> obj = TextReader.TextReader("TextReader.py")
>>> obj.readline()
'1: #!/usr/local/bin/python'
- >>> # (more invocations of obj.readline() here)
- ... obj.readline()
- '7: class TextReader:'
+ >>> obj.readline()
+ '2: '
+ >>> obj.readline()
+ '3: class TextReader:'
>>> import pickle
- >>> pickle.dump(obj,open('save.p', 'wb'))
+ >>> pickle.dump(obj, open('save.p', 'wb'))
If you want to see that :mod:`pickle` works across Python processes, start
another Python session, before continuing. What follows can happen from either
@@ -762,7 +769,7 @@
>>> import pickle
>>> reader = pickle.load(open('save.p', 'rb'))
>>> reader.readline()
- '8: "Print and number lines in a text file."'
+ '4: """Print and number lines in a text file."""'
.. seealso::
Modified: doctools/trunk/Doc-3k/library/random.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/random.rst (original)
+++ doctools/trunk/Doc-3k/library/random.rst Mon Aug 13 22:52:56 2007
@@ -103,7 +103,7 @@
.. versionadded:: 2.1
.. versionchanged:: 2.3
- Instead of jumping to a specific state, *n* steps ahead, :meth:`jumpahead(n)`
+ Instead of jumping to a specific state, *n* steps ahead, ``jumpahead(n)``
jumps to another state likely to be separated by many steps.
@@ -185,7 +185,7 @@
.. function:: uniform(a, b)
- Return a random real number *N* such that ``a <= N < b``.
+ Return a random floating point number *N* such that ``a <= N < b``.
.. function:: betavariate(alpha, beta)
@@ -228,10 +228,10 @@
.. function:: vonmisesvariate(mu, kappa)
- *mu* is the mean angle, expressed in radians between 0 and 2\**pi*, and *kappa*
+ *mu* is the mean angle, expressed in radians between 0 and 2\*\ *pi*, and *kappa*
is the concentration parameter, which must be greater than or equal to zero. If
*kappa* is equal to zero, this distribution reduces to a uniform random angle
- over the range 0 to 2\**pi*.
+ over the range 0 to 2\*\ *pi*.
.. function:: paretovariate(alpha)
@@ -244,8 +244,8 @@
Weibull distribution. *alpha* is the scale parameter and *beta* is the shape
parameter.
-Alternative Generators:
+Alternative Generators:
.. class:: WichmannHill([seed])
Modified: doctools/trunk/Doc-3k/library/shutil.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/shutil.rst (original)
+++ doctools/trunk/Doc-3k/library/shutil.rst Mon Aug 13 22:52:56 2007
@@ -66,7 +66,7 @@
.. function:: copy2(src, dst)
Similar to :func:`copy`, but last access time and last modification time are
- copied as well. This is similar to the Unix command :program:`cp` :option:`-p`.
+ copied as well. This is similar to the Unix command :program:`cp -p`.
.. function:: copytree(src, dst[, symlinks])
@@ -137,9 +137,10 @@
above, with the docstring omitted. It demonstrates many of the other functions
provided by this module. ::
- def copytree(src, dst, symlinks=0):
+ def copytree(src, dst, symlinks=False):
names = os.listdir(src)
- os.mkdir(dst)
+ os.makedirs(dst)
+ errors = []
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
@@ -151,6 +152,20 @@
copytree(srcname, dstname, symlinks)
else:
copy2(srcname, dstname)
+ # XXX What about devices, sockets etc.?
except (IOError, os.error) as why:
- print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))
+ errors.append((srcname, dstname, str(why)))
+ # catch the Error from the recursive copytree so that we can
+ # continue with other files
+ except Error as err:
+ errors.extend(err.args[0])
+ try:
+ copystat(src, dst)
+ except WindowsError:
+ # can't copy file access times on Windows
+ pass
+ except OSError as why:
+ errors.extend((src, dst, str(why)))
+ if errors:
+ raise Error, errors
Modified: doctools/trunk/Doc-3k/library/tempfile.rst
==============================================================================
--- doctools/trunk/Doc-3k/library/tempfile.rst (original)
+++ doctools/trunk/Doc-3k/library/tempfile.rst Mon Aug 13 22:52:56 2007
@@ -81,12 +81,13 @@
.. function:: mkstemp([suffix[, prefix[, dir[, text]]]])
- Creates a temporary file in the most secure manner possible. There are no race
- conditions in the file's creation, assuming that the platform properly
- implements the :const:`O_EXCL` flag for :func:`os.open`. The file is readable
- and writable only by the creating user ID. If the platform uses permission bits
- to indicate whether a file is executable, the file is executable by no one. The
- file descriptor is not inherited by child processes.
+ Creates a temporary file in the most secure manner possible. There are no
+ race conditions in the file's creation, assuming that the platform properly
+ implements the :const:`os.O_EXCL` flag for :func:`os.open`. The file is
+ readable and writable only by the creating user ID. If the platform uses
+ permission bits to indicate whether a file is executable, the file is
+ executable by no one. The file descriptor is not inherited by child
+ processes.
Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible for
deleting the temporary file when done with it.
@@ -173,7 +174,7 @@
* On RiscOS, the directory named by the :envvar:`Wimp$ScrapDir` environment
variable.
- * On Windows, the directories :file:`C:$\\TEMP`, :file:`C:$\\TMP`,
+ * On Windows, the directories :file:`C:\\TEMP`, :file:`C:\\TMP`,
:file:`\\TEMP`, and :file:`\\TMP`, in that order.
* On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and
@@ -185,8 +186,8 @@
.. function:: gettempdir()
Return the directory currently selected to create temporary files in. If
- ``tempdir`` is not ``None``, this simply returns its contents; otherwise, the
- search described above is performed, and the result returned.
+ :data:`tempdir` is not ``None``, this simply returns its contents; otherwise,
+ the search described above is performed, and the result returned.
.. data:: template
Modified: doctools/trunk/TODO
==============================================================================
--- doctools/trunk/TODO (original)
+++ doctools/trunk/TODO Mon Aug 13 22:52:56 2007
@@ -9,3 +9,4 @@
- look at the old tools/ scripts, what functionality should be rewritten
- add search via Xapian?
- optionally have a contents tree view in the sidebar (AJAX based)?
+- .. caveat?
\ No newline at end of file
More information about the Python-checkins
mailing list