]> granicus.if.org Git - python/commitdiff
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166...
authorGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 21:55:17 +0000 (21:55 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 21:55:17 +0000 (21:55 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68133 | antoine.pitrou | 2009-01-01 16:38:03 +0100 (Thu, 01 Jan 2009) | 1 line

  fill in actual issue number in tests
........
  r68134 | hirokazu.yamamoto | 2009-01-01 16:45:39 +0100 (Thu, 01 Jan 2009) | 2 lines

  Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
  file with `str' filename on Windows.
........
  r68141 | benjamin.peterson | 2009-01-01 17:43:12 +0100 (Thu, 01 Jan 2009) | 1 line

  fix highlighting
........
  r68142 | benjamin.peterson | 2009-01-01 18:29:49 +0100 (Thu, 01 Jan 2009) | 2 lines

  welcome to 2009, Python!
........
  r68145 | amaury.forgeotdarc | 2009-01-02 01:03:54 +0100 (Fri, 02 Jan 2009) | 5 lines

  #4801 _collections module fails to build on cygwin.

  _PyObject_GC_TRACK is the macro version of PyObject_GC_Track,
  and according to documentation it should not be used for extension modules.
........
  r68146 | ronald.oussoren | 2009-01-02 11:44:46 +0100 (Fri, 02 Jan 2009) | 2 lines

  Fix for issue4472: "configure --enable-shared doesn't work on OSX"
........
  r68148 | ronald.oussoren | 2009-01-02 11:48:31 +0100 (Fri, 02 Jan 2009) | 2 lines

  Forgot to add a NEWS item in my previous checkin
........
  r68149 | ronald.oussoren | 2009-01-02 11:50:48 +0100 (Fri, 02 Jan 2009) | 2 lines

  Fix for issue4780
........
  r68159 | ronald.oussoren | 2009-01-02 15:48:17 +0100 (Fri, 02 Jan 2009) | 2 lines

  Fix for issue 1627952
........
  r68160 | ronald.oussoren | 2009-01-02 15:52:09 +0100 (Fri, 02 Jan 2009) | 2 lines

  Fix for issue r1737832
........
  r68161 | ronald.oussoren | 2009-01-02 16:00:05 +0100 (Fri, 02 Jan 2009) | 3 lines

  Fix for issue 1149804
........
  r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines

  Fix for issue 4472 is incompatible with Cygwin, this patch
  should fix that.
........
  r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line

  document PyMemberDef
........
  r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines

  #4811: fix markup glitches (mostly remains of the conversion),
  found by Gabriel Genellina.
........
  r68172 | martin.v.loewis | 2009-01-02 21:32:55 +0100 (Fri, 02 Jan 2009) | 2 lines

  Issue #4075: Use OutputDebugStringW in Py_FatalError.
........
  r68173 | martin.v.loewis | 2009-01-02 21:40:14 +0100 (Fri, 02 Jan 2009) | 2 lines

  Issue #4051: Prevent conflict of UNICODE macros in cPickle.
........
  r68174 | benjamin.peterson | 2009-01-02 21:47:27 +0100 (Fri, 02 Jan 2009) | 1 line

  fix compilation on non-Windows platforms
........
  r68179 | raymond.hettinger | 2009-01-02 22:26:45 +0100 (Fri, 02 Jan 2009) | 1 line

  Issue #4615.  Document how to use itertools for de-duping.
........
  r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines

  Remove useless string literal.
........
  r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines

  Fix indentation.
........
  r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines

  Set eol-style correctly for mp_distributing.py.
........
  r68214 | georg.brandl | 2009-01-03 20:44:48 +0100 (Sat, 03 Jan 2009) | 2 lines

  Make indentation consistent.
........
  r68215 | georg.brandl | 2009-01-03 21:15:14 +0100 (Sat, 03 Jan 2009) | 2 lines

  Fix role name.
........
  r68217 | georg.brandl | 2009-01-03 21:30:15 +0100 (Sat, 03 Jan 2009) | 2 lines

  Add rstlint, a little tool to find subtle markup problems and inconsistencies in the Doc sources.
........
  r68218 | georg.brandl | 2009-01-03 21:38:59 +0100 (Sat, 03 Jan 2009) | 2 lines

  Recognize usage of the default role.
........
  r68219 | georg.brandl | 2009-01-03 21:47:01 +0100 (Sat, 03 Jan 2009) | 2 lines

  Fix uses of the default role.
........
  r68220 | georg.brandl | 2009-01-03 21:55:06 +0100 (Sat, 03 Jan 2009) | 2 lines

  Remove trailing whitespace.
........
  r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines

  Remove tabs from the documentation.
........
  r68222 | georg.brandl | 2009-01-03 22:11:58 +0100 (Sat, 03 Jan 2009) | 2 lines

  Disable the line length checker by default.
........

186 files changed:
Doc/ACKS.txt
Doc/Makefile
Doc/c-api/arg.rst
Doc/c-api/buffer.rst
Doc/c-api/conversion.rst
Doc/c-api/file.rst
Doc/c-api/init.rst
Doc/c-api/long.rst
Doc/c-api/module.rst
Doc/c-api/reflection.rst
Doc/c-api/sequence.rst
Doc/c-api/set.rst
Doc/c-api/structures.rst
Doc/distutils/apiref.rst
Doc/distutils/builtdist.rst
Doc/distutils/configfile.rst
Doc/distutils/packageindex.rst
Doc/distutils/setupscript.rst
Doc/distutils/uploading.rst
Doc/documenting/markup.rst
Doc/extending/building.rst
Doc/extending/extending.rst
Doc/extending/newtypes.rst
Doc/extending/windows.rst
Doc/glossary.rst
Doc/howto/curses.rst
Doc/howto/doanddont.rst
Doc/howto/functional.rst
Doc/howto/regex.rst
Doc/howto/sockets.rst
Doc/howto/unicode.rst
Doc/howto/urllib2.rst
Doc/howto/webservers.rst
Doc/includes/mp_distributing.py
Doc/install/index.rst
Doc/library/abc.rst
Doc/library/aifc.rst
Doc/library/al.rst
Doc/library/ast.rst
Doc/library/audioop.rst
Doc/library/bastion.rst
Doc/library/bdb.rst
Doc/library/bsddb.rst
Doc/library/bz2.rst
Doc/library/cd.rst
Doc/library/cmath.rst
Doc/library/codeop.rst
Doc/library/collections.rst
Doc/library/compiler.rst
Doc/library/configparser.rst
Doc/library/cookielib.rst
Doc/library/crypt.rst
Doc/library/csv.rst
Doc/library/ctypes.rst
Doc/library/datetime.rst
Doc/library/decimal.rst
Doc/library/difflib.rst
Doc/library/dircache.rst
Doc/library/dis.rst
Doc/library/dl.rst
Doc/library/email.mime.rst
Doc/library/fileinput.rst
Doc/library/fl.rst
Doc/library/fm.rst
Doc/library/fpformat.rst
Doc/library/fractions.rst
Doc/library/functions.rst
Doc/library/gettext.rst
Doc/library/gl.rst
Doc/library/gzip.rst
Doc/library/heapq.rst
Doc/library/htmllib.rst
Doc/library/idle.rst
Doc/library/imageop.rst
Doc/library/imgfile.rst
Doc/library/io.rst
Doc/library/itertools.rst
Doc/library/jpeg.rst
Doc/library/json.rst
Doc/library/locale.rst
Doc/library/macos.rst
Doc/library/mailbox.rst
Doc/library/marshal.rst
Doc/library/math.rst
Doc/library/mhlib.rst
Doc/library/mmap.rst
Doc/library/msvcrt.rst
Doc/library/multiprocessing.rst
Doc/library/mutex.rst
Doc/library/nntplib.rst
Doc/library/numbers.rst
Doc/library/operator.rst
Doc/library/optparse.rst
Doc/library/os.rst
Doc/library/ossaudiodev.rst
Doc/library/othergui.rst
Doc/library/parser.rst
Doc/library/pdb.rst
Doc/library/pickle.rst
Doc/library/popen2.rst
Doc/library/profile.rst
Doc/library/pyexpat.rst
Doc/library/re.rst
Doc/library/repr.rst
Doc/library/rexec.rst
Doc/library/rlcompleter.rst
Doc/library/robotparser.rst
Doc/library/sched.rst
Doc/library/sgmllib.rst
Doc/library/shutil.rst
Doc/library/signal.rst
Doc/library/simplexmlrpcserver.rst
Doc/library/smtplib.rst
Doc/library/socket.rst
Doc/library/socketserver.rst
Doc/library/sqlite3.rst
Doc/library/ssl.rst
Doc/library/statvfs.rst
Doc/library/stdtypes.rst
Doc/library/string.rst
Doc/library/stringio.rst
Doc/library/subprocess.rst
Doc/library/sunaudio.rst
Doc/library/sys.rst
Doc/library/tempfile.rst
Doc/library/tk.rst
Doc/library/tkinter.rst
Doc/library/trace.rst
Doc/library/traceback.rst
Doc/library/turtle.rst
Doc/library/undoc.rst
Doc/library/unicodedata.rst
Doc/library/unittest.rst
Doc/library/urllib.rst
Doc/library/urllib2.rst
Doc/library/urlparse.rst
Doc/library/warnings.rst
Doc/library/webbrowser.rst
Doc/library/wsgiref.rst
Doc/library/xml.etree.elementtree.rst
Doc/library/xmlrpclib.rst
Doc/library/zipfile.rst
Doc/library/zipimport.rst
Doc/license.rst
Doc/reference/expressions.rst
Doc/reference/lexical_analysis.rst
Doc/reference/simple_stmts.rst
Doc/tools/rstlint.py [new file with mode: 0755]
Doc/tutorial/classes.rst
Doc/tutorial/controlflow.rst
Doc/tutorial/datastructures.rst
Doc/tutorial/errors.rst
Doc/tutorial/index.rst
Doc/tutorial/inputoutput.rst
Doc/tutorial/interpreter.rst
Doc/tutorial/introduction.rst
Doc/tutorial/modules.rst
Doc/tutorial/stdlib.rst
Doc/tutorial/stdlib2.rst
Doc/tutorial/whatnow.rst
Doc/using/cmdline.rst
Doc/using/unix.rst
Doc/using/windows.rst
Doc/whatsnew/2.0.rst
Doc/whatsnew/2.1.rst
Doc/whatsnew/2.2.rst
Doc/whatsnew/2.3.rst
Doc/whatsnew/2.4.rst
Doc/whatsnew/2.5.rst
Doc/whatsnew/2.6.rst
LICENSE
Lib/plat-mac/EasyDialogs.py
Lib/plat-mac/macostools.py
Lib/plat-mac/videoreader.py
Lib/test/test_deque.py
Lib/test/test_dict.py
Lib/test/test_set.py
Makefile.pre.in
Misc/NEWS
Modules/_collectionsmodule.c
Modules/_fileio.c
Modules/cPickle.c
Parser/asdl.py
Python/getcopyright.c
Python/pythonrun.c
README

index 0bff6bdefeb55ce7e0713741bdb14c5d04099020..38c3dc22a82121769d4f28ff656ab024495ace76 100644 (file)
@@ -60,6 +60,7 @@ docs@python.org), and we'll be glad to correct the problem.
    * Peter Funk
    * Lele Gaifax
    * Matthew Gallagher
+   * Gabriel Genellina
    * Ben Gertzfield
    * Nadim Ghaznavi
    * Jonathan Giddy
index be05d4b1d9bfd293b6300976a1a7575d407e4bfa..b1b0e8512943740e5931de02ebcae26c11bc3a9d 100644 (file)
@@ -14,7 +14,7 @@ DISTVERSION  = $(shell $(PYTHON) tools/sphinxext/patchlevel.py)
 ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
                 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
 
-.PHONY: help checkout update build html htmlhelp clean coverage dist
+.PHONY: help checkout update build html htmlhelp clean coverage dist check
 
 help:
        @echo "Please use \`make <target>' where <target> is one of"
@@ -141,3 +141,5 @@ dist:
        cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
        cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
 
+check:
+       $(PYTHON) tools/rstlint.py -i tools
index 144a36545d6b5a1320825f62e22db61449a4ed39..9d14d1c21d904e0967fe8e5fd8062374dad3f36f 100644 (file)
@@ -46,12 +46,12 @@ variable(s) whose address should be passed.
    :ctype:`Py_ssize_t` rather than an int.
 
 ``s*`` (string, Unicode, or any buffer compatible object) [Py_buffer \*]
-  Similar to ``s#``, this code fills a Py_buffer structure provided by the caller.
-  The buffer gets locked, so that the caller can subsequently use the buffer even
-  inside a ``Py_BEGIN_ALLOW_THREADS`` block; the caller is responsible for calling
-  ``PyBuffer_Release`` with the structure after it has processed the data.
+   Similar to ``s#``, this code fills a Py_buffer structure provided by the caller.
+   The buffer gets locked, so that the caller can subsequently use the buffer even
+   inside a ``Py_BEGIN_ALLOW_THREADS`` block; the caller is responsible for calling
+   ``PyBuffer_Release`` with the structure after it has processed the data.
 
-  .. versionadded:: 2.6
+   .. versionadded:: 2.6
 
 ``z`` (string or ``None``) [const char \*]
    Like ``s``, but the Python object may also be ``None``, in which case the C
@@ -63,7 +63,7 @@ variable(s) whose address should be passed.
 ``z*`` (string or ``None`` or any buffer compatible object) [Py_buffer*]
    This is to ``s*`` as ``z`` is to ``s``.
 
-  .. versionadded:: 2.6
+   .. versionadded:: 2.6
 
 ``u`` (Unicode object) [Py_UNICODE \*]
    Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of
@@ -261,6 +261,7 @@ variable(s) whose address should be passed.
 
 ``w*`` (read-write byte-oriented buffer) [Py_buffer \*]
    This is to ``w`` what ``s*`` is to ``s``.
+
    .. versionadded:: 2.6
 
 ``(items)`` (tuple) [*matching-items*]
index bf367d8890fa275ea686ca9a99cab7136b4a820c..6b80ad6a4400a42a322402efdd9f21b53ab58e59 100644 (file)
@@ -30,7 +30,7 @@ returning data from the target object.
 
 .. index:: single: PyBufferProcs
 
-More information on the buffer interface is provided in the section 
+More information on the buffer interface is provided in the section
 :ref:`buffer-structs`, under the description for :ctype:`PyBufferProcs`.
 
 A "buffer object" is defined in the :file:`bufferobject.h` header (included by
index 5a747ef1d6a988f799445e3ed56bd2812da9c4ef..0c81bc087c45892b78c6558d5a665fea174dc165 100644 (file)
@@ -77,7 +77,7 @@ The following functions provide locale-independent string to number conversions.
 
    .. versionadded:: 2.4
 
+
 .. cfunction:: double PyOS_ascii_atof(const char *nptr)
 
    Convert a string to a :ctype:`double` in a locale-independent way.
@@ -86,7 +86,7 @@ The following functions provide locale-independent string to number conversions.
 
    See the Unix man page :manpage:`atof(2)` for details.
 
-   
+
 .. cfunction:: char * PyOS_stricmp(char *s1, char *s2)
 
    Case insensitive comparison of strings. The function works almost
index aa753e5699528f204f511737bfd56708a5816132..5d74355f4b0f2f5e20cf749690a03ca53f453ef2 100644 (file)
@@ -63,8 +63,8 @@ change in future releases of Python.
    Return the file object associated with *p* as a :ctype:`FILE\*`.
 
    If the caller will ever use the returned :ctype:`FILE\*` object while
-   the GIL is released it must also call the `PyFile_IncUseCount` and
-   `PyFile_DecUseCount` functions described below as appropriate.
+   the GIL is released it must also call the :cfunc:`PyFile_IncUseCount` and
+   :cfunc:`PyFile_DecUseCount` functions described below as appropriate.
 
 
 .. cfunction:: void PyFile_IncUseCount(PyFileObject \*p)
@@ -72,13 +72,13 @@ change in future releases of Python.
    Increments the PyFileObject's internal use count to indicate
    that the underlying :ctype:`FILE\*` is being used.
    This prevents Python from calling f_close() on it from another thread.
-   Callers of this must call `PyFile_DecUseCount` when they are
+   Callers of this must call :cfunc:`PyFile_DecUseCount` when they are
    finished with the :ctype:`FILE\*`.  Otherwise the file object will
    never be closed by Python.
 
    The GIL must be held while calling this function.
 
-   The suggested use is to call this after `PyFile_AsFile` just before
+   The suggested use is to call this after :cfunc:`PyFile_AsFile` just before
    you release the GIL.
 
    .. versionadded:: 2.6
@@ -88,7 +88,7 @@ change in future releases of Python.
 
    Decrements the PyFileObject's internal unlocked_count member to
    indicate that the caller is done with its own use of the :ctype:`FILE\*`.
-   This may only be called to undo a prior call to `PyFile_IncUseCount`.
+   This may only be called to undo a prior call to :cfunc:`PyFile_IncUseCount`.
 
    The GIL must be held while calling this function.
 
index 17fb82eb273e7a4dc083c063d0e70ec347d2ca49..a4a202ad0a81f22a6d4057839af07586ae81bda1 100644 (file)
@@ -902,7 +902,7 @@ in previous versions.
 
    Return a tuple of function call counts.  There are constants defined for the
    positions within the tuple:
-   
+
    +-------------------------------+-------+
    | Name                          | Value |
    +===============================+=======+
@@ -928,7 +928,7 @@ in previous versions.
    +-------------------------------+-------+
    | :const:`PCALL_POP`            | 10    |
    +-------------------------------+-------+
-   
+
    :const:`PCALL_FAST_FUNCTION` means no argument tuple needs to be created.
    :const:`PCALL_FASTER_FUNCTION` means that the fast-path frame setup code is used.
 
index 57015dbd85eb6b183b255c12a87fc30bc7f64946..4b21fd4cc7f3a890193ba33e21e945440b5ec8d6 100644 (file)
@@ -126,7 +126,7 @@ Long Integer Objects
 
    Return a C :ctype:`long` representation of the contents of *pylong*.  If
    *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised
-   and ``-1`` will be returned. 
+   and ``-1`` will be returned.
 
 
 .. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
index 9d16ef560cb2345beeb6363fd3ec1b2dff18d91d..abac599f2dacb0d2880235379e38d4f534485b6d 100644 (file)
@@ -106,7 +106,7 @@ There are only a few functions special to module objects.
 
 .. cfunction:: int PyModule_AddIntMacro(PyObject *module, macro)
 
-   Add an int constant to *module*. The name and the value are taken from 
+   Add an int constant to *module*. The name and the value are taken from
    *macro*. For example ``PyModule_AddConstant(module, AF_INET)`` adds the int
    constant *AF_INET* with the value of *AF_INET* to *module*.
    Return ``-1`` on error, ``0`` on success.
index 8a96ce3d5021fa14209d281414d711c1691a9fe3..822c59343ca1b2b8a31e03e13554e4d9b24e4acb 100644 (file)
@@ -15,7 +15,7 @@ Reflection
 
    Return a dictionary of the local variables in the current execution frame,
    or *NULL* if no frame is currently executing.
-   
+
 
 .. cfunction:: PyObject* PyEval_GetGlobals()
 
index e16c2e3a59f12e256396d2fc61b12220791200fb..7f5e77a6791ca9aa1d1338f24a5119b6aa34167a 100644 (file)
@@ -143,9 +143,9 @@ Sequence Protocol
 
    Return the underlying array of PyObject pointers.  Assumes that *o* was returned
    by :cfunc:`PySequence_Fast` and *o* is not *NULL*.
-   
+
    Note, if a list gets resized, the reallocation may relocate the items array.
-   So, only use the underlying array pointer in contexts where the sequence 
+   So, only use the underlying array pointer in contexts where the sequence
    cannot change.
 
    .. versionadded:: 2.4
index c6b097dae43a1f464f122d1a8b90f42189e74cee..a60ccd623797aa134e3ff453d5f7179c1ee0a7ab 100644 (file)
@@ -101,7 +101,7 @@ the constructor functions work with any iterable Python object.
 
    .. versionchanged:: 2.6
       Now guaranteed to return a brand-new :class:`frozenset`.  Formerly,
-      frozensets of zero-length were a singleton.  This got in the way of 
+      frozensets of zero-length were a singleton.  This got in the way of
       building-up new frozensets with :meth:`PySet_Add`.
 
 The following functions and macros are available for instances of :class:`set`
index 725f554d03de6239f0271a700fcbbd4f7e220041..f8635e58e4cf5aad3b9f5720ef4c9e5720d5d9f8 100644 (file)
@@ -205,6 +205,69 @@ definition with the same method name.
    .. versionadded:: 2.4
 
 
+.. ctype:: PyMemberDef
+
+   Structure which describes an attribute of a type which corresponds to a C
+   struct member.  It's fields are:
+
+   +------------------+-------------+-------------------------------+
+   | Field            | C Type      | Meaning                       |
+   +==================+=============+===============================+
+   | :attr:`name`     | char \*     | name of the member            |
+   +------------------+-------------+-------------------------------+
+   | :attr:`type`     | int         | the type of the member in the |
+   |                  |             | C struct                      |
+   +------------------+-------------+-------------------------------+
+   | :attr:`offset`   | Py_ssize_t  | the offset in bytes that the  |
+   |                  |             | member is located on the      |
+   |                  |             | type's object struct          |
+   +------------------+-------------+-------------------------------+
+   | :attr:`flags`    | int         | flag bits indicating if the   |
+   |                  |             | field should be read-only or  |
+   |                  |             | writable                      |
+   +------------------+-------------+-------------------------------+
+   | :attr:`doc`      | char \*     | points to the contents of the |
+   |                  |             | docstring                     |
+   +------------------+-------------+-------------------------------+
+
+   :attr:`type` can be one of many ``T_`` macros corresponding to various C
+   types.  When the member is accessed in Python, it will be converted to the
+   equivalent Python type.
+
+   =============== ==================
+   Macro name      C type
+   =============== ==================
+   T_SHORT         short
+   T_INT           int
+   T_LONG          long
+   T_FLOAT         float
+   T_DOUBLE        double
+   T_STRING        char \*
+   T_OBJECT        PyObject \*
+   T_OBJECT_EX     PyObject \*
+   T_CHAR          char
+   T_BYTE          char
+   T_UNBYTE        unsigned char
+   T_UINT          unsigned int
+   T_USHORT        unsigned short
+   T_ULONG         unsigned long
+   T_BOOL          char
+   T_LONGLONG      long long
+   T_ULONGLONG     unsigned long long
+   T_PYSSIZET      Py_ssize_t
+   =============== ==================
+
+   :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` differ in that
+   :cmacro:`T_OBJECT` returns ``None`` if the member is *NULL* and
+   :cmacro:`T_OBJECT_EX` raises an :exc:`AttributeError`.
+
+   :attr:`flags` can be 0 for write and read access or :cmacro:`READONLY` for
+   read-only access.  Using :cmacro:`T_STRING` for :attr:`type` implies
+   :cmacro:`READONLY`.  Only :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` can be
+   deleted.  (They are set to *NULL*).
+
+
+
 .. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
 
    Return a bound method object for an extension type implemented in C.  This can
index 4a0d354547b3a1c0d55a49704d27060ba61678c6..4d65de039426d6e772c9a5032a895aa2da4baea1 100644 (file)
@@ -104,7 +104,7 @@ setup script). Indirectly provides the  :class:`distutils.dist.Distribution` and
    | *package_dir*      | A mapping of package to        | a dictionary                                                |
    |                    | directory names                |                                                             |
    +--------------------+--------------------------------+-------------------------------------------------------------+
-   
+
 
 
 .. function:: run_setup(script_name[, script_args=None, stop_after='run'])
@@ -188,9 +188,10 @@ the full reference.
    |                        | for C/C++ header files (in     |                           |
    |                        | Unix form for portability)     |                           |
    +------------------------+--------------------------------+---------------------------+
-   | *define_macros*        | list of macros to define; each | (string,string)  tuple or |
-   |                        | macro is defined using a       | (name,``None``)           |
-   |                        | 2-tuple, where 'value' is      |                           |
+   | *define_macros*        | list of macros to define; each | (string, string) tuple or |
+   |                        | macro is defined using a       | (name, ``None``)          |
+   |                        | 2-tuple ``(name, value)``,     |                           |
+   |                        | where *value* is               |                           |
    |                        | either the string to define it |                           |
    |                        | to or ``None`` to define it    |                           |
    |                        | without a particular value     |                           |
@@ -754,7 +755,7 @@ This module provides the following functions.
       standard output, otherwise do nothing.
 
 .. % \subsection{Compiler-specific modules}
-.. % 
+.. %
 .. % The following modules implement concrete subclasses of the abstract
 .. % \class{CCompiler} class. They should not be instantiated directly, but should
 .. % be created using \function{distutils.ccompiler.new_compiler()} factory
@@ -858,7 +859,7 @@ Contains :class:`MWerksCompiler`, an implementation of the abstract
 Macintosh. Needs work to support CW on Windows or Mac OS X.
 
 .. % \subsection{Utility modules}
-.. % 
+.. %
 .. % The following modules all provide general utility functions. They haven't
 .. % all been documented yet.
 
@@ -1109,13 +1110,13 @@ other utility module.
 
    For MacOS X systems the OS version reflects the minimal version on which
    binaries will run (that is, the value of ``MACOSX_DEPLOYMENT_TARGET``
-   during the build of Python), not the OS version of the current system. 
+   during the build of Python), not the OS version of the current system.
 
    For universal binary builds on MacOS X the architecture value reflects
    the univeral binary status instead of the architecture of the current
-   processor. For 32-bit universal binaries the architecture is ``fat``, 
-   for 64-bit universal binaries the architecture is ``fat64``, and 
-   for 4-way universal binaries the architecture is ``universal``. 
+   processor. For 32-bit universal binaries the architecture is ``fat``,
+   for 64-bit universal binaries the architecture is ``fat64``, and
+   for 4-way universal binaries the architecture is ``universal``.
 
    Examples of returned values on MacOS X:
 
@@ -1692,7 +1693,7 @@ lines, and joining lines with backslashes.
 
 .. % todo
 .. % \section{Distutils Commands}
-.. % 
+.. %
 .. % This part of Distutils implements the various Distutils commands, such
 .. % as \code{build}, \code{install} \&c. Each command is implemented as a
 .. % separate module, with the command name as the name of the module.
index 58b62f834e14d9e9ddc01f521d8d37b30262afff..672faee34c0b8b126ade6ab6ec82d9dc875ef951 100644 (file)
@@ -268,13 +268,13 @@ file winds up deep in the "build tree," in a temporary directory created by
 .. % \longprogramopt{spec-file} option; used in conjunction with
 .. % \longprogramopt{spec-only}, this gives you an opportunity to customize
 .. % the \file{.spec} file manually:
-.. % 
+.. %
 .. % \ begin{verbatim}
 .. % > python setup.py bdist_rpm --spec-only
 .. % # ...edit dist/FooBar-1.0.spec
 .. % > python setup.py bdist_rpm --spec-file=dist/FooBar-1.0.spec
 .. % \ end{verbatim}
-.. % 
+.. %
 .. % (Although a better way to do this is probably to override the standard
 .. % \command{bdist\_rpm} command with one that writes whatever else you want
 .. % to the \file{.spec} file.)
@@ -334,31 +334,31 @@ The installer file will be written to the "distribution directory" --- normally
 Cross-compiling on Windows
 ==========================
 
-Starting with Python 2.6, distutils is capable of cross-compiling between 
-Windows platforms.  In practice, this means that with the correct tools 
+Starting with Python 2.6, distutils is capable of cross-compiling between
+Windows platforms.  In practice, this means that with the correct tools
 installed, you can use a 32bit version of Windows to create 64bit extensions
 and vice-versa.
 
-To build for an alternate platform, specify the :option:`--plat-name` option 
-to the build command.  Valid values are currently 'win32', 'win-amd64' and 
+To build for an alternate platform, specify the :option:`--plat-name` option
+to the build command.  Valid values are currently 'win32', 'win-amd64' and
 'win-ia64'.  For example, on a 32bit version of Windows, you could execute::
 
    python setup.py build --plat-name=win-amd64
 
-to build a 64bit version of your extension.  The Windows Installers also 
+to build a 64bit version of your extension.  The Windows Installers also
 support this option, so the command::
 
    python setup.py build --plat-name=win-amd64 bdist_wininst
 
 would create a 64bit installation executable on your 32bit version of Windows.
 
-To cross-compile, you must download the Python source code and cross-compile 
+To cross-compile, you must download the Python source code and cross-compile
 Python itself for the platform you are targetting - it is not possible from a
 binary installtion of Python (as the .lib etc file for other platforms are
-not included.)  In practice, this means the user of a 32 bit operating 
-system will need to use Visual Studio 2008 to open the 
-:file:`PCBuild/PCbuild.sln` solution in the Python source tree and build the 
-"x64" configuration of the 'pythoncore' project before cross-compiling 
+not included.)  In practice, this means the user of a 32 bit operating
+system will need to use Visual Studio 2008 to open the
+:file:`PCBuild/PCbuild.sln` solution in the Python source tree and build the
+"x64" configuration of the 'pythoncore' project before cross-compiling
 extensions is possible.
 
 Note that by default, Visual Studio 2008 does not install 64bit compilers or
index 0ccd5fd3e8b9bd48ac65d7a9770eeadb5cd953ac..890047c08e54327f306c27eccd9d8b40492b31f4 100644 (file)
@@ -63,7 +63,7 @@ universal :option:`--help` option, e.g. ::
      --include-dirs (-I)  list of directories to search for header files
      --define (-D)        C preprocessor macros to define
      --undef (-U)         C preprocessor macros to undefine
-     --swig-opts          list of SWIG command line options        
+     --swig-opts          list of SWIG command line options
    [...]
 
 Note that an option spelled :option:`--foo-bar` on the command-line  is spelled
index ef81d6465a5e25895ee675628b8fbd8c79bf5a47..3715c82480a47ca983f81c15d7ec4677322b076c 100644 (file)
@@ -72,7 +72,7 @@ If you want to define another server a new section can be created::
    index-servers =
      pypi
      other
+
    [pypi]
    repository: <repository-url>
    username: <username>
@@ -91,4 +91,4 @@ Or even with the section name::
 
    python setup.py register -r other
 
+
index 7971878bba813b5fb029f7548e205bafd43d8221..997dab7fb3d995b89b0eb68181571573d6251482 100644 (file)
@@ -213,7 +213,7 @@ This warning notwithstanding, options to SWIG can be currently passed like
 this::
 
    setup(...,
-         ext_modules=[Extension('_foo', ['foo.i'], 
+         ext_modules=[Extension('_foo', ['foo.i'],
                                 swig_opts=['-modern', '-I../include'])],
          py_modules=['foo'],
         )
index 52d6d5b7c7f93967e9b577b0ef34a7f206ad22e0..66f712b75839f96f761e8278a909177cc8c744d4 100644 (file)
@@ -35,9 +35,9 @@ uploaded file using GPG (GNU Privacy Guard).  The  :program:`gpg` program must
 be available for execution on the system :envvar:`PATH`.  You can also specify
 which key to use for signing using the :option:`--identity=*name*` option.
 
-Other :command:`upload` options include  :option:`--repository=*url*` 
-or :option:`--repository=*section*` where `url` is the url of the server
-and `section` the name of the section in :file:`$HOME/.pypirc`, and
+Other :command:`upload` options include :option:`--repository=<url>` or
+:option:`--repository=<section>` where *url* is the url of the server and
+*section* the name of the section in :file:`$HOME/.pypirc`, and
 :option:`--show-response` (which displays the full response text from the PyPI
 server for help in debugging upload problems).
 
index e6f6a5268f59cc21ba4b780f4eabf9e5f10c20f2..80b43b9850329d375c2f20af2392155e2a3a76c5 100644 (file)
@@ -508,7 +508,7 @@ in a different style:
    curly braces to indicate a "variable" part, as in ``:file:``.
 
    If you don't need the "variable part" indication, use the standard
-   ````code```` instead.   
+   ````code```` instead.
 
 .. describe:: var
 
@@ -599,7 +599,7 @@ units as well as normal text:
    Example::
 
       .. versionadded:: 2.5
-         The `spam` parameter.
+         The *spam* parameter.
 
    Note that there must be no blank line between the directive head and the
    explanation; this is to make these blocks visually continuous in the markup.
@@ -760,14 +760,14 @@ the definition of the symbol.  There is this directive:
    Blank lines are not allowed within ``productionlist`` directive arguments.
 
    The definition can contain token names which are marked as interpreted text
-   (e.g. ``sum ::= `integer` "+" `integer```) -- this generates cross-references
+   (e.g. ``unaryneg ::= "-" `integer```) -- this generates cross-references
    to the productions of these tokens.
 
    Note that no further reST parsing is done in the production, so that you
    don't have to escape ``*`` or ``|`` characters.
 
 
-.. XXX describe optional first parameter 
+.. XXX describe optional first parameter
 
 The following is an example taken from the Python Reference Manual::
 
index 1c7b53f603cc43c43d8e32209b9b633ca039618f..f4d95b2b0e1ec3d03942918cbb5578a454a37fd4 100644 (file)
@@ -39,7 +39,7 @@ Python file, which, in the most simple case, could look like this::
 
 With this :file:`setup.py`, and a file :file:`demo.c`, running ::
 
-   python setup.py build 
+   python setup.py build
 
 will compile :file:`demo.c`, and produce an extension module named ``demo`` in
 the :file:`build` directory. Depending on the system, the module file will end
index 8c2268ec7b8ed5e989a8cfda268d55e420831890..8e453849e8f8b54c48802a121b43e0d92c4d854b 100644 (file)
@@ -471,7 +471,7 @@ Later, when it is time to call the function, you call the C function
 :cfunc:`PyEval_CallObject`.  This function has two arguments, both pointers to
 arbitrary Python objects: the Python function, and the argument list.  The
 argument list must always be a tuple object, whose length is the number of
-arguments.  To call the Python function with no arguments, pass in NULL, or 
+arguments.  To call the Python function with no arguments, pass in NULL, or
 an empty tuple; to call it with one argument, pass a singleton tuple.
 :cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero
 or more format codes between parentheses.  For example::
@@ -510,7 +510,7 @@ If this is not possible or desirable, the exception should be cleared by calling
    if (result == NULL)
        return NULL; /* Pass error back */
    ...use result...
-   Py_DECREF(result); 
+   Py_DECREF(result);
 
 Depending on the desired interface to the Python callback function, you may also
 have to provide an argument list to :cfunc:`PyEval_CallObject`.  In some cases
@@ -535,7 +535,7 @@ Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before
 the error check!  Also note that strictly speaking this code is not complete:
 :cfunc:`Py_BuildValue` may run out of memory, and this should be checked.
 
-You may also call a function with keyword arguments by using 
+You may also call a function with keyword arguments by using
 :cfunc:`PyEval_CallObjectWithKeywords`.  As in the above example, we use
 :cfunc:`Py_BuildValue` to construct the dictionary. ::
 
@@ -671,7 +671,7 @@ Philbrick (philbrick@hks.com)::
 
    static PyObject *
    keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
-   {  
+   {
        int voltage;
        char *state = "a stiff";
        char *action = "voom";
@@ -679,11 +679,11 @@ Philbrick (philbrick@hks.com)::
 
        static char *kwlist[] = {"voltage", "state", "action", "type", NULL};
 
-       if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist, 
+       if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist,
                                         &voltage, &state, &action, &type))
-           return NULL; 
+           return NULL;
 
-       printf("-- This parrot wouldn't %s if you put %i Volts through it.\n", 
+       printf("-- This parrot wouldn't %s if you put %i Volts through it.\n",
               action, voltage);
        printf("-- Lovely plumage, the %s -- It's %s!\n", type, state);
 
index ba39951adcc7abc7715293e7dcf3326f4fdf6b1a..030de57f7774600b94e9136e5fd4f98bf8994e95 100644 (file)
@@ -840,8 +840,8 @@ As you can see, the source code closely resembles the :class:`Noddy` examples in
 previous sections. We will break down the main differences between them. ::
 
    typedef struct {
-       PyListObject list;
-       int state;
+       PyListObject list;
+       int state;
    } Shoddy;
 
 The primary difference for derived type objects is that the base type's object
@@ -854,10 +854,10 @@ be safely cast to both *PyListObject\** and *Shoddy\**. ::
    static int
    Shoddy_init(Shoddy *self, PyObject *args, PyObject *kwds)
    {
-       if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
-               return -1;
-       self->state = 0;
-       return 0;
+       if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
+          return -1;
+       self->state = 0;
+       return 0;
    }
 
 In the :attr:`__init__` method for our type, we can see how to call through to
@@ -876,18 +876,18 @@ the module's :cfunc:`init` function. ::
    PyMODINIT_FUNC
    initshoddy(void)
    {
-       PyObject *m;
+       PyObject *m;
 
-       ShoddyType.tp_base = &PyList_Type;
-       if (PyType_Ready(&ShoddyType) < 0)
-               return;
+       ShoddyType.tp_base = &PyList_Type;
+       if (PyType_Ready(&ShoddyType) < 0)
+           return;
 
-       m = Py_InitModule3("shoddy", NULL, "Shoddy module");
-       if (m == NULL)
-               return;
+       m = Py_InitModule3("shoddy", NULL, "Shoddy module");
+       if (m == NULL)
+           return;
 
-       Py_INCREF(&ShoddyType);
-       PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
+       Py_INCREF(&ShoddyType);
+       PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
    }
 
 Before calling :cfunc:`PyType_Ready`, the type structure must have the
@@ -1167,7 +1167,7 @@ structure::
    typedef struct PyMethodDef {
        char        *ml_name;       /* method name */
        PyCFunction  ml_meth;       /* implementation function */
-       int              ml_flags;      /* flags */
+       int          ml_flags;      /* flags */
        char        *ml_doc;        /* docstring */
    } PyMethodDef;
 
@@ -1234,7 +1234,7 @@ As with the :attr:`tp_methods` table, a sentinel entry with a :attr:`name` value
 of *NULL* is required.
 
 .. XXX Descriptors need to be explained in more detail somewhere, but not here.
-   
+
    Descriptor objects have two handler functions which correspond to the
    \member{tp_getattro} and \member{tp_setattro} handlers.  The
    \method{__get__()} handler is a function which is passed the descriptor,
index 1675a0d0d264709e26adfe9d5fd9083020b5f585..aac1d2dc98ec77d21032d2cf8ceec9befab16e08 100644 (file)
@@ -102,7 +102,7 @@ described here are distributed with the Python sources in the
    and it should call :cfunc:`Py_InitModule` with the string ``"spam"`` as its
    first argument (use the minimal :file:`example.c` in this directory as a guide).
    By convention, it lives in a file called :file:`spam.c` or :file:`spammodule.c`.
-   The output file should be called :file:`spam.pyd` (in Release mode) or  
+   The output file should be called :file:`spam.pyd` (in Release mode) or
    :file:`spam_d.pyd` (in Debug mode). The extension :file:`.pyd` was chosen
    to avoid confusion with a system library :file:`spam.dll` to which your module
    could be a Python interface.
index 2894f358d90defb388f0d8acb7b7a0ca43474074..0eb31117502a1af0dbeb2ac26b78bfb1292273df 100644 (file)
@@ -11,7 +11,7 @@ Glossary
    ``>>>``
       The default Python prompt of the interactive shell.  Often seen for code
       examples which can be executed interactively in the interpreter.
-    
+
    ``...``
       The default Python prompt of the interactive shell when entering code for
       an indented code block or within a pair of matching left and right
@@ -50,11 +50,11 @@ Glossary
       A value associated with an object which is referenced by name using
       dotted expressions.  For example, if an object *o* has an attribute
       *a* it would be referenced as *o.a*.
-    
+
    BDFL
       Benevolent Dictator For Life, a.k.a. `Guido van Rossum
       <http://www.python.org/~guido/>`_, Python's creator.
-    
+
    bytecode
       Python source code is compiled into bytecode, the internal representation
       of a Python program in the interpreter.  The bytecode is also cached in
@@ -67,11 +67,11 @@ Glossary
       A template for creating user-defined objects. Class definitions
       normally contain method definitions which operate on instances of the
       class.
-    
+
    classic class
       Any class which does not inherit from :class:`object`.  See
       :term:`new-style class`.  Classic classes will be removed in Python 3.0.
-    
+
    coercion
       The implicit conversion of an instance of one type to another during an
       operation which involves two arguments of the same type.  For example,
@@ -84,7 +84,7 @@ Glossary
       ``operator.add(3.0, 4.5)``.  Without coercion, all arguments of even
       compatible types would have to be normalized to the same value by the
       programmer, e.g., ``float(3)+4.5`` rather than just ``3+4.5``.
-    
+
    complex number
       An extension of the familiar real number system in which all numbers are
       expressed as a sum of a real part and an imaginary part.  Imaginary
@@ -96,7 +96,7 @@ Glossary
       :mod:`math` module, use :mod:`cmath`.  Use of complex numbers is a fairly
       advanced mathematical feature.  If you're not aware of a need for them,
       it's almost certain you can safely ignore them.
-    
+
    context manager
       An object which controls the environment seen in a :keyword:`with`
       statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
@@ -138,7 +138,7 @@ Glossary
       class methods, static methods, and reference to super classes.
 
       For more information about descriptors' methods, see :ref:`descriptors`.
-    
+
    dictionary
       An associative array, where arbitrary keys are mapped to values.  The use
       of :class:`dict` closely resembles that for :class:`list`, but the keys can
@@ -152,8 +152,8 @@ Glossary
       of the enclosing class, function or module.  Since it is available via
       introspection, it is the canonical place for documentation of the
       object.
-    
-   duck-typing 
+
+   duck-typing
       A pythonic programming style which determines an object's type by inspection
       of its method or attribute signature rather than by explicit relationship
       to some type object ("If it looks like a duck and quacks like a duck, it
@@ -163,13 +163,13 @@ Glossary
       :func:`isinstance`. (Note, however, that duck-typing can be complemented
       with abstract base classes.) Instead, it typically employs :func:`hasattr`
       tests or :term:`EAFP` programming.
-    
+
    EAFP
       Easier to ask for forgiveness than permission.  This common Python coding
       style assumes the existence of valid keys or attributes and catches
       exceptions if the assumption proves false.  This clean and fast style is
       characterized by the presence of many :keyword:`try` and :keyword:`except`
-      statements.  The technique contrasts with the :term:`LBYL` style 
+      statements.  The technique contrasts with the :term:`LBYL` style
       common to many other languages such as C.
 
    expression
@@ -195,14 +195,14 @@ Glossary
       which are not compatible with the current interpreter.  For example, the
       expression ``11/4`` currently evaluates to ``2``. If the module in which
       it is executed had enabled *true division* by executing::
-    
+
          from __future__ import division
-    
+
       the expression ``11/4`` would evaluate to ``2.75``.  By importing the
       :mod:`__future__` module and evaluating its variables, you can see when a
       new feature was first added to the language and when it will become the
       default::
-    
+
          >>> import __future__
          >>> __future__.division
          _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)
@@ -211,7 +211,7 @@ Glossary
       The process of freeing memory when it is not used anymore.  Python
       performs garbage collection via reference counting and a cyclic garbage
       collector that is able to detect and break reference cycles.
-    
+
    generator
       A function which returns an iterator.  It looks like a normal function
       except that values are returned to the caller using a :keyword:`yield`
@@ -221,21 +221,21 @@ Glossary
       stopped at the :keyword:`yield` keyword (returning the result) and is
       resumed there when the next element is requested by calling the
       :meth:`next` method of the returned iterator.
-    
+
       .. index:: single: generator expression
-    
+
    generator expression
       An expression that returns a generator.  It looks like a normal expression
       followed by a :keyword:`for` expression defining a loop variable, range,
       and an optional :keyword:`if` expression.  The combined expression
       generates values for an enclosing function::
-    
+
          >>> sum(i*i for i in range(10))         # sum of squares 0, 1, 4, ... 81
          285
-    
+
    GIL
       See :term:`global interpreter lock`.
-    
+
    global interpreter lock
       The lock used by Python threads to assure that only one thread
       executes in the :term:`CPython` :term:`virtual machine` at a time.
@@ -261,21 +261,21 @@ Glossary
       containers (such as lists or dictionaries) are.  Objects which are
       instances of user-defined classes are hashable by default; they all
       compare unequal, and their hash value is their :func:`id`.
-    
+
    IDLE
       An Integrated Development Environment for Python.  IDLE is a basic editor
       and interpreter environment which ships with the standard distribution of
       Python.  Good for beginners, it also serves as clear example code for
       those wanting to implement a moderately sophisticated, multi-platform GUI
       application.
-    
+
    immutable
       An object with a fixed value.  Immutable objects include numbers, strings and
       tuples.  Such an object cannot be altered.  A new object has to
       be created if a different value has to be stored.  They play an important
       role in places where a constant hash value is needed, for example as a key
       in a dictionary.
-    
+
    integer division
       Mathematical division discarding any remainder.  For example, the
       expression ``11/4`` currently evaluates to ``2`` in contrast to the
@@ -287,7 +287,7 @@ Glossary
       divided by a float will result in a float value, possibly with a decimal
       fraction.  Integer division can be forced by using the ``//`` operator
       instead of the ``/`` operator.  See also :term:`__future__`.
-    
+
    interactive
       Python has an interactive interpreter which means you can enter
       statements and expressions at the interpreter prompt, immediately
@@ -295,7 +295,7 @@ Glossary
       arguments (possibly by selecting it from your computer's main
       menu). It is a very powerful way to test out new ideas or inspect
       modules and packages (remember ``help(x)``).
-    
+
    interpreted
       Python is an interpreted language, as opposed to a compiled one,
       though the distinction can be blurry because of the presence of the
@@ -304,7 +304,7 @@ Glossary
       Interpreted languages typically have a shorter development/debug cycle
       than compiled ones, though their programs generally also run more
       slowly.  See also :term:`interactive`.
-    
+
    iterable
       A container object capable of returning its members one at a
       time. Examples of iterables include all sequence types (such as
@@ -320,7 +320,7 @@ Glossary
       statement does that automatically for you, creating a temporary unnamed
       variable to hold the iterator for the duration of the loop.  See also
       :term:`iterator`, :term:`sequence`, and :term:`generator`.
-    
+
    iterator
       An object representing a stream of data.  Repeated calls to the iterator's
       :meth:`next` method return successive items in the stream.  When no more
@@ -335,7 +335,7 @@ Glossary
       :func:`iter` function or use it in a :keyword:`for` loop.  Attempting this
       with an iterator will just return the same exhausted iterator object used
       in the previous iteration pass, making it appear like an empty container.
-    
+
       More information can be found in :ref:`typeiter`.
 
    keyword argument
@@ -359,7 +359,7 @@ Glossary
       A built-in Python :term:`sequence`.  Despite its name it is more akin
       to an array in other languages than to a linked list since access to
       elements are O(1).
-    
+
    list comprehension
       A compact way to process all or part of the elements in a sequence and
       return a list with the results.  ``result = ["0x%02x" % x for x in
@@ -367,11 +367,11 @@ Glossary
       even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if`
       clause is optional.  If omitted, all elements in ``range(256)`` are
       processed.
-    
+
    mapping
       A container object (such as :class:`dict`) which supports arbitrary key
       lookups using the special method :meth:`__getitem__`.
-    
+
    metaclass
       The class of a class.  Class definitions create a class name, a class
       dictionary, and a list of base classes.  The metaclass is responsible for
@@ -390,7 +390,7 @@ Glossary
       of an instance of that class, the method will get the instance object as
       its first :term:`argument` (which is usually called ``self``).
       See :term:`function` and :term:`nested scope`.
-    
+
    mutable
       Mutable objects can change their value but keep their :func:`id`.  See
       also :term:`immutable`.
@@ -407,7 +407,7 @@ Glossary
       :func:`collections.namedtuple`.  The latter approach automatically
       provides extra features such as a self-documenting representation like
       ``Employee(name='jones', title='programmer')``.
-    
+
    namespace
       The place where a variable is stored.  Namespaces are implemented as
       dictionaries.  There are the local, global and builtin namespaces as well
@@ -419,7 +419,7 @@ Glossary
       :func:`random.seed` or :func:`itertools.izip` makes it clear that those
       functions are implemented by the :mod:`random` and :mod:`itertools`
       modules, respectively.
-    
+
    nested scope
       The ability to refer to a variable in an enclosing definition.  For
       instance, a function defined inside another function can refer to
@@ -427,7 +427,7 @@ Glossary
       reference and not for assignment which will always write to the innermost
       scope.  In contrast, local variables both read and write in the innermost
       scope.  Likewise, global variables read and write to the global namespace.
-    
+
    new-style class
       Any class which inherits from :class:`object`.  This includes all built-in
       types like :class:`list` and :class:`dict`.  Only new-style classes can
@@ -440,7 +440,7 @@ Glossary
       Any data with state (attributes or value) and defined behavior
       (methods).  Also the ultimate base class of any :term:`new-style
       class`.
-    
+
    positional argument
       The arguments assigned to local names inside a function or method,
       determined by the order in which they were given in the call.  ``*`` is
@@ -448,7 +448,7 @@ Glossary
       definition), or pass several arguments as a list to a function.  See
       :term:`argument`.
 
-   Python 3000 
+   Python 3000
       Nickname for the next major Python version, 3.0 (coined long ago
       when the release of version 3 was something in the distant future.)  This
       is also abbreviated "Py3k".
@@ -460,7 +460,7 @@ Glossary
       to loop over all elements of an iterable using a :keyword:`for`
       statement.  Many other languages don't have this type of construct, so
       people unfamiliar with Python sometimes use a numerical counter instead::
-     
+
           for i in range(len(food)):
               print food[i]
 
@@ -483,7 +483,7 @@ Glossary
       dictionaries.  Though popular, the technique is somewhat tricky to get
       right and is best reserved for rare cases where there are large numbers of
       instances in a memory-critical application.
-    
+
    sequence
       An :term:`iterable` which supports efficient element access using integer
       indices via the :meth:`__getitem__` special method and defines a
@@ -529,7 +529,7 @@ Glossary
    virtual machine
       A computer defined entirely in software.  Python's virtual machine
       executes the :term:`bytecode` emitted by the bytecode compiler.
-    
+
    Zen of Python
       Listing of Python design principles and philosophies that are helpful in
       understanding and using the language.  The listing can be found by typing
index 1e1e2f787c68b024f62221f125e26fc048161bfe..2d964c393ca8098475d35de90e800723871627e4 100644 (file)
@@ -297,7 +297,7 @@ So, to display a reverse-video status line on the top line of the screen, you
 could code::
 
    stdscr.addstr(0, 0, "Current mode: Typing mode",
-             curses.A_REVERSE)
+                 curses.A_REVERSE)
    stdscr.refresh()
 
 The curses library also supports color on those terminals that provide it, The
@@ -399,8 +399,8 @@ string.  It can optionally be limited to a fixed number of characters. ::
 
    curses.echo()            # Enable echoing of characters
 
-   # Get a 15-character string, with the cursor on the top line 
-   s = stdscr.getstr(0,0, 15)  
+   # Get a 15-character string, with the cursor on the top line
+   s = stdscr.getstr(0,0, 15)
 
 The Python :mod:`curses.textpad` module supplies something better. With it, you
 can turn a window into a text box that supports an Emacs-like set of
index a3a91ede4bf5acc45ca5e2e4cecb0f4a2a2f538b..a56fb8c13e87dfbf98d926b66bf87d7471065459 100644 (file)
@@ -1,5 +1,5 @@
 ************************************
-  Idioms and Anti-Idioms in Python  
+  Idioms and Anti-Idioms in Python
 ************************************
 
 :Author: Moshe Zadka
@@ -127,7 +127,7 @@ Bad example::
    # bar.py
    from foo import a
    if something():
-       a = 2 # danger: foo.a != a 
+       a = 2 # danger: foo.a != a
 
 Good example::
 
@@ -303,6 +303,6 @@ It is usually much better to use the implicit continuation inside parenthesis:
 
 This version is bulletproof::
 
-   value = (foo.bar()['first'][0]*baz.quux(1, 2)[5:9] 
+   value = (foo.bar()['first'][0]*baz.quux(1, 2)[5:9]
            + calculate_number(10, 20)*forbulate(500, 360))
 
index b717f80bf0543c23874fd1f949220c2937ac043b..d589f36b31726011acd414dc5249b3ad176d64a9 100644 (file)
@@ -145,7 +145,7 @@ than a large function that performs a complicated transformation.  Small
 functions are also easier to read and to check for errors.
 
 
-Ease of debugging and testing 
+Ease of debugging and testing
 -----------------------------
 
 Testing and debugging a functional-style program is easier.
@@ -213,7 +213,7 @@ You can experiment with the iteration interface manually:
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     StopIteration
-    >>>      
+    >>>
 
 Python expects iterable objects in several different contexts, the most
 important being the ``for`` statement.  In the statement ``for X in Y``, Y must
@@ -362,7 +362,7 @@ Generator expressions are surrounded by parentheses ("()") and list
 comprehensions are surrounded by square brackets ("[]").  Generator expressions
 have the form::
 
-    ( expression for expr in sequence1 
+    ( expression for expr in sequence1
                  if condition1
                  for expr2 in sequence2
                  if condition2
@@ -404,7 +404,7 @@ equivalent to the following Python code::
                  if not (conditionN):
                      continue   # Skip this element
 
-                 # Output the value of 
+                 # Output the value of
                  # the expression.
 
 This means that when there are multiple ``for...in`` clauses but no ``if``
@@ -418,8 +418,8 @@ list is 9 elements long:
     >>> seq1 = 'abc'
     >>> seq2 = (1,2,3)
     >>> [(x,y) for x in seq1 for y in seq2]
-    [('a', 1), ('a', 2), ('a', 3), 
-     ('b', 1), ('b', 2), ('b', 3), 
+    [('a', 1), ('a', 2), ('a', 3),
+     ('b', 1), ('b', 2), ('b', 3),
      ('c', 1), ('c', 2), ('c', 3)]
 
 To avoid introducing an ambiguity into Python's grammar, if ``expression`` is
@@ -585,7 +585,7 @@ And here's an example of changing the counter:
     9
     >>> print it.next()
     Traceback (most recent call last):
-      File ``t.py'', line 15, in ?
+      File "t.py", line 15, in ?
         print it.next()
     StopIteration
 
@@ -759,7 +759,7 @@ values:
     True
     >>> all([0,1,0])
     False
-    >>> all([0,0,0]) 
+    >>> all([0,0,0])
     False
     >>> all([1,1,1])
     True
@@ -845,7 +845,7 @@ Fredrik Lundh once suggested the following set of rules for refactoring uses of
 4) Convert the lambda to a def statement, using that name.
 5) Remove the comment.
 
-I really like these rules, but you're free to disagree 
+I really like these rules, but you're free to disagree
 about whether this lambda-free style is better.
 
 
@@ -970,7 +970,7 @@ operators.  Some examples are ``operator.add(a, b)`` (adds two values),
 ``itertools.starmap(func, iter)`` assumes that the iterable will return a stream
 of tuples, and calls ``f()`` using these tuples as the arguments::
 
-    itertools.starmap(os.path.join, 
+    itertools.starmap(os.path.join,
                       [('/usr', 'bin', 'java'), ('/bin', 'python'),
                        ('/usr', 'bin', 'perl'),('/usr', 'bin', 'ruby')])
     =>
@@ -1039,9 +1039,9 @@ value and an iterator for the elements with that key.
 
 ::
 
-    city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'), 
+    city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),
                  ('Anchorage', 'AK'), ('Nome', 'AK'),
-                 ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'), 
+                 ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'),
                  ...
                 ]
 
@@ -1056,7 +1056,7 @@ value and an iterator for the elements with that key.
     where
     iterator-1 =>
       ('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL')
-    iterator-2 => 
+    iterator-2 =>
       ('Anchorage', 'AK'), ('Nome', 'AK')
     iterator-3 =>
       ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')
@@ -1150,7 +1150,7 @@ is equivalent to ::
 
     >>> double(add(5, 6))
     22
-                    
+
 The ``unpack`` keyword is provided to work around the fact that Python functions
 are not always `fully curried <http://en.wikipedia.org/wiki/Currying>`__.  By
 default, it is expected that the ``inner`` function will return a single object
@@ -1159,15 +1159,15 @@ and that the ``outer`` function will take a single argument. Setting the
 will be expanded before being passed to ``outer``. Put simply, ::
 
     compose(f, g)(5, 6)
-                    
+
 is equivalent to::
 
     f(g(5, 6))
-                    
+
 while ::
 
     compose(f, g, unpack=True)(5, 6)
-                    
+
 is equivalent to::
 
     f(*g(5, 6))
@@ -1178,20 +1178,20 @@ version that will compose any number of functions. We'll use ``reduce()``,
 ``functional`` and ``functools``). ::
 
     from functional import compose, partial
-        
+
     multi_compose = partial(reduce, compose)
-        
-    
+
+
 We can also use ``map()``, ``compose()`` and ``partial()`` to craft a version of
 ``"".join(...)`` that converts its arguments to string::
 
     from functional import compose, partial
-        
+
     join = compose("".join, partial(map, str))
 
 
 ``flip(func)``
-                    
+
 ``flip()`` wraps the callable in ``func`` and causes it to receive its
 non-keyword arguments in reverse order. ::
 
@@ -1206,7 +1206,7 @@ non-keyword arguments in reverse order. ::
     (7, 6, 5)
 
 ``foldl(func, start, iterable)``
-                    
+
 ``foldl()`` takes a binary function, a starting value (usually some kind of
 'zero'), and an iterable.  The function is applied to the starting value and the
 first element of the list, then the result of that and the second element of the
@@ -1220,7 +1220,7 @@ is equivalent to::
 
     f(f(f(0, 1), 2), 3)
 
-    
+
 ``foldl()`` is roughly equivalent to the following recursive function::
 
     def foldl(func, start, seq):
@@ -1298,7 +1298,7 @@ for text processing, in the section titled "Utilizing Higher-Order Functions in
 Text Processing".
 
 Mertz also wrote a 3-part series of articles on functional programming
-for IBM's DeveloperWorks site; see 
+for IBM's DeveloperWorks site; see
 `part 1 <http://www-128.ibm.com/developerworks/library/l-prog.html>`__,
 `part 2 <http://www-128.ibm.com/developerworks/library/l-prog2.html>`__, and
 `part 3 <http://www-128.ibm.com/developerworks/linux/library/l-prog3.html>`__,
index 2f085e56aaf189bb9c86dbf59e53ff7ac95398a1..051e7d70e8fcbfad42c7872032e584e83fae1946 100644 (file)
@@ -1,7 +1,7 @@
 .. _regex-howto:
 
 ****************************
-  Regular Expression HOWTO  
+  Regular Expression HOWTO
 ****************************
 
 :Author: A.M. Kuchling
@@ -611,7 +611,7 @@ of each one.
    is to read? ::
 
       charref = re.compile(r"""
-       &[#]                 # Start of a numeric entity reference
+       &[#]                # Start of a numeric entity reference
        (
            0[0-7]+         # Octal form
          | [0-9]+          # Decimal form
@@ -732,7 +732,7 @@ given location, they can obviously be matched an infinite number of times.
       >>> p = re.compile('\bclass\b')
       >>> print p.search('no class at all')
       None
-      >>> print p.search('\b' + 'class' + '\b')  
+      >>> print p.search('\b' + 'class' + '\b')
       <re.MatchObject instance at 80c3ee0>
 
    Second, inside a character class, where there's no use for this assertion,
@@ -917,7 +917,7 @@ module::
 
    InternalDate = re.compile(r'INTERNALDATE "'
            r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
-       r'(?P<year>[0-9][0-9][0-9][0-9])'
+           r'(?P<year>[0-9][0-9][0-9][0-9])'
            r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
            r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
            r'"')
@@ -1236,9 +1236,9 @@ It's important to keep this distinction in mind.  Remember,  :func:`match` will
 only report a successful match which will start at 0; if the match wouldn't
 start at zero,  :func:`match` will *not* report it. ::
 
-   >>> print re.match('super', 'superstition').span()  
+   >>> print re.match('super', 'superstition').span()
    (0, 5)
-   >>> print re.match('super', 'insuperable')    
+   >>> print re.match('super', 'insuperable')
    None
 
 On the other hand, :func:`search` will scan forward through the string,
index 2747f812cc612038ee53733dd4aba02d1f9aedbe..3cba020bb84171f64f2b7ec5adca52e63d554735 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  Socket Programming HOWTO  
+  Socket Programming HOWTO
 ****************************
 
 :Author: Gordon McMillan
@@ -63,7 +63,7 @@ your browser did something like the following::
    #create an INET, STREAMing socket
    s = socket.socket(
        socket.AF_INET, socket.SOCK_STREAM)
-   #now connect to the web server on port 80 
+   #now connect to the web server on port 80
    # - the normal http port
    s.connect(("www.mcmillan-inc.com", 80))
 
@@ -78,7 +78,7 @@ creates a "server socket". ::
    #create an INET, STREAMing socket
    serversocket = socket.socket(
        socket.AF_INET, socket.SOCK_STREAM)
-   #bind the socket to a public host, 
+   #bind the socket to a public host,
    # and a well-known port
    serversocket.bind((socket.gethostname(), 80))
    #become a server socket
@@ -185,38 +185,38 @@ Assuming you don't want to end the connection, the simplest solution is a fixed
 length message::
 
    class mysocket:
-       '''demonstration class only 
+       '''demonstration class only
          - coded for clarity, not efficiency
        '''
 
        def __init__(self, sock=None):
-       if sock is None:
-           self.sock = socket.socket(
-               socket.AF_INET, socket.SOCK_STREAM)
-       else:
-           self.sock = sock
+           if sock is None:
+               self.sock = socket.socket(
+                   socket.AF_INET, socket.SOCK_STREAM)
+           else:
+               self.sock = sock
 
        def connect(self, host, port):
-       self.sock.connect((host, port))
+           self.sock.connect((host, port))
 
        def mysend(self, msg):
-       totalsent = 0
-       while totalsent < MSGLEN:
-           sent = self.sock.send(msg[totalsent:])
-           if sent == 0:
-               raise RuntimeError, \
-                   "socket connection broken"
-           totalsent = totalsent + sent
+           totalsent = 0
+           while totalsent < MSGLEN:
+               sent = self.sock.send(msg[totalsent:])
+               if sent == 0:
+                   raise RuntimeError, \
+                       "socket connection broken"
+               totalsent = totalsent + sent
 
        def myreceive(self):
-       msg = ''
-       while len(msg) < MSGLEN:
-           chunk = self.sock.recv(MSGLEN-len(msg))
-           if chunk == '':
-               raise RuntimeError, \
-                   "socket connection broken"
-           msg = msg + chunk
-       return msg
+           msg = ''
+           while len(msg) < MSGLEN:
+               chunk = self.sock.recv(MSGLEN-len(msg))
+               if chunk == '':
+                   raise RuntimeError, \
+                       "socket connection broken"
+               msg = msg + chunk
+           return msg
 
 The sending code here is usable for almost any messaging scheme - in Python you
 send strings, and you can use ``len()`` to determine its length (even if it has
@@ -343,9 +343,9 @@ you'll have little trouble with it in C. ::
 
    ready_to_read, ready_to_write, in_error = \
                   select.select(
-                     potential_readers, 
-                     potential_writers, 
-                     potential_errs, 
+                     potential_readers,
+                     potential_writers,
+                     potential_errs,
                      timeout)
 
 You pass ``select`` three lists: the first contains all sockets that you might
index d5dec63baaf717aef441a764fdbe7a78f4a95cd9..c09a72d6b0a2ca285356ce12dbf68ef2f3afdc7e 100644 (file)
@@ -30,8 +30,8 @@ For a while people just wrote programs that didn't display accents.  I remember
 looking at Apple ][ BASIC programs, published in French-language publications in
 the mid-1980s, that had lines like these::
 
-       PRINT "FICHIER EST COMPLETE."
-       PRINT "CARACTERE NON ACCEPTE."
+   PRINT "FICHIER EST COMPLETE."
+   PRINT "CARACTERE NON ACCEPTE."
 
 Those messages should contain accents, and they just look wrong to someone who
 can read French.
@@ -89,11 +89,11 @@ standard, a code point is written using the notation U+12ca to mean the
 character with value 0x12ca (4810 decimal).  The Unicode standard contains a lot
 of tables listing characters and their corresponding code points::
 
-       0061    'a'; LATIN SMALL LETTER A
-       0062    'b'; LATIN SMALL LETTER B
-       0063    'c'; LATIN SMALL LETTER C
-        ...
-       007B    '{'; LEFT CURLY BRACKET
+   0061    'a'; LATIN SMALL LETTER A
+   0062    'b'; LATIN SMALL LETTER B
+   0063    'c'; LATIN SMALL LETTER C
+   ...
+   007B    '{'; LEFT CURLY BRACKET
 
 Strictly, these definitions imply that it's meaningless to say 'this is
 character U+12ca'.  U+12ca is a code point, which represents some particular
@@ -122,8 +122,8 @@ The first encoding you might think of is an array of 32-bit integers.  In this
 representation, the string "Python" would look like this::
 
        P           y           t           h           o           n
-    0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00 
-       0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 
+    0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00
+       0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 
 This representation is straightforward but using it presents a number of
 problems.
@@ -181,7 +181,7 @@ UTF-8.)  UTF-8 uses the following rules:
    between 128 and 255.
 3. Code points >0x7ff are turned into three- or four-byte sequences, where each
    byte of the sequence is between 128 and 255.
-    
+
 UTF-8 has several convenient properties:
 
 1. It can handle any Unicode code point.
@@ -252,7 +252,7 @@ characters greater than 127 will be treated as errors::
     >>> unicode('abcdef' + chr(255))
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
-    UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6: 
+    UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6:
                         ordinal not in range(128)
 
 The ``errors`` argument specifies the response when the input string can't be
@@ -264,7 +264,7 @@ Unicode result).  The following examples show the differences::
     >>> unicode('\x80abc', errors='strict')
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
-    UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: 
+    UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0:
                         ordinal not in range(128)
     >>> unicode('\x80abc', errors='replace')
     u'\ufffdabc'
@@ -350,7 +350,7 @@ interprets the string using the given encoding::
     >>> u2 = utf8_version.decode('utf-8')            # Decode using UTF-8
     >>> u == u2                                      # The two strings match
     True
+
 The low-level routines for registering and accessing the available encodings are
 found in the :mod:`codecs` module.  However, the encoding and decoding functions
 returned by this module are usually more low-level than is comfortable, so I'm
@@ -362,8 +362,8 @@ covered here.  Consult the Python documentation to learn more about this module.
 The most commonly used part of the :mod:`codecs` module is the
 :func:`codecs.open` function which will be discussed in the section on input and
 output.
-            
-            
+
+
 Unicode Literals in Python Source Code
 --------------------------------------
 
@@ -381,10 +381,10 @@ arbitrary code point.  Octal escapes can go up to U+01ff, which is octal 777.
 
     >>> s = u"a\xac\u1234\u20ac\U00008000"
                ^^^^ two-digit hex escape
-                   ^^^^^^ four-digit Unicode escape 
+                   ^^^^^^ four-digit Unicode escape
                                ^^^^^^^^^^ eight-digit Unicode escape
     >>> for c in s:  print ord(c),
-    ... 
+    ...
     97 172 4660 8364 32768
 
 Using escape sequences for code points greater than 127 is fine in small doses,
@@ -404,10 +404,10 @@ either the first or second line of the source file::
 
     #!/usr/bin/env python
     # -*- coding: latin-1 -*-
-    
+
     u = u'abcdé'
     print ord(u[-1])
-    
+
 The syntax is inspired by Emacs's notation for specifying variables local to a
 file.  Emacs supports many different variables, but Python only supports
 'coding'.  The ``-*-`` symbols indicate to Emacs that the comment is special;
@@ -427,10 +427,10 @@ encoding declaration::
 When you run it with Python 2.4, it will output the following warning::
 
     amk:~$ python p263.py
-    sys:1: DeprecationWarning: Non-ASCII character '\xe9' 
-         in file p263.py on line 2, but no encoding declared; 
+    sys:1: DeprecationWarning: Non-ASCII character '\xe9'
+         in file p263.py on line 2, but no encoding declared;
          see http://www.python.org/peps/pep-0263.html for details
-  
+
 
 Unicode Properties
 ------------------
@@ -446,13 +446,13 @@ The following program displays some information about several characters, and
 prints the numeric value of one particular character::
 
     import unicodedata
-    
+
     u = unichr(233) + unichr(0x0bf2) + unichr(3972) + unichr(6000) + unichr(13231)
-    
+
     for i, c in enumerate(u):
         print i, '%04x' % ord(c), unicodedata.category(c),
         print unicodedata.name(c)
-    
+
     # Get numeric value of second character
     print unicodedata.numeric(u[1])
 
@@ -597,25 +597,25 @@ encoding and a list of Unicode strings will be returned, while passing an 8-bit
 path will return the 8-bit versions of the filenames.  For example, assuming the
 default filesystem encoding is UTF-8, running the following program::
 
-       fn = u'filename\u4500abc'
-       f = open(fn, 'w')
-       f.close()
+   fn = u'filename\u4500abc'
+   f = open(fn, 'w')
+   f.close()
 
-       import os
-       print os.listdir('.')
-       print os.listdir(u'.')
+   import os
+   print os.listdir('.')
+   print os.listdir(u'.')
 
 will produce the following output::
 
-       amk:~$ python t.py
-       ['.svn', 'filename\xe4\x94\x80abc', ...]
-       [u'.svn', u'filename\u4500abc', ...]
+   amk:~$ python t.py
+   ['.svn', 'filename\xe4\x94\x80abc', ...]
+   [u'.svn', u'filename\u4500abc', ...]
 
 The first list contains UTF-8-encoded filenames, and the second list contains
 the Unicode versions.
 
 
-       
+
 Tips for Writing Unicode-aware Programs
 ---------------------------------------
 
@@ -661,7 +661,7 @@ this code::
         unicode_name = filename.decode(encoding)
         f = open(unicode_name, 'r')
         # ... return contents of file ...
-        
+
 However, if an attacker could specify the ``'base64'`` encoding, they could pass
 ``'L2V0Yy9wYXNzd2Q='``, which is the base-64 encoded form of the string
 ``'/etc/passwd'``, to read a system file.  The above code looks for ``'/'``
@@ -697,32 +697,32 @@ Version 1.02: posted August 16 2005.  Corrects factual errors.
 .. comment Describe obscure -U switch somewhere?
 .. comment Describe use of codecs.StreamRecoder and StreamReaderWriter
 
-.. comment 
+.. comment
    Original outline:
 
    - [ ] Unicode introduction
        - [ ] ASCII
        - [ ] Terms
-          - [ ] Character
-          - [ ] Code point
-        - [ ] Encodings
-           - [ ] Common encodings: ASCII, Latin-1, UTF-8
+           - [ ] Character
+           - [ ] Code point
+         - [ ] Encodings
+            - [ ] Common encodings: ASCII, Latin-1, UTF-8
        - [ ] Unicode Python type
-          - [ ] Writing unicode literals
-              - [ ] Obscurity: -U switch
-          - [ ] Built-ins
-              - [ ] unichr()
-              - [ ] ord()
-              - [ ] unicode() constructor
-          - [ ] Unicode type
-              - [ ] encode(), decode() methods
+           - [ ] Writing unicode literals
+               - [ ] Obscurity: -U switch
+           - [ ] Built-ins
+               - [ ] unichr()
+               - [ ] ord()
+               - [ ] unicode() constructor
+           - [ ] Unicode type
+               - [ ] encode(), decode() methods
        - [ ] Unicodedata module for character properties
        - [ ] I/O
-          - [ ] Reading/writing Unicode data into files
-              - [ ] Byte-order marks
-          - [ ] Unicode filenames
+           - [ ] Reading/writing Unicode data into files
+               - [ ] Byte-order marks
+           - [ ] Unicode filenames
        - [ ] Writing Unicode programs
-          - [ ] Do everything in Unicode
-          - [ ] Declaring source code encodings (PEP 263)
+           - [ ] Do everything in Unicode
+           - [ ] Declaring source code encodings (PEP 263)
        - [ ] Other issues
-          - [ ] Building Python (UCS2, UCS4)
+           - [ ] Building Python (UCS2, UCS4)
index 72f394afd313891363544647846907c8dcf4b813..96f2ce204538abfea13ae35e64707f2db07ec28d 100644 (file)
@@ -10,7 +10,7 @@
     HOWTO, available at `urllib2 - Le Manuel manquant
     <http://www.voidspace.org.uk/python/articles/urllib2_francais.shtml>`_.
 
+
 
 Introduction
 ============
@@ -19,9 +19,9 @@ Introduction
 
     You may also find useful the following article on fetching web resources
     with Python :
-    
+
     * `Basic Authentication <http://www.voidspace.org.uk/python/articles/authentication.shtml>`_
-    
+
         A tutorial on *Basic Authentication*, with examples in Python.
 
 **urllib2** is a `Python <http://www.python.org>`_ module for fetching URLs
@@ -98,7 +98,7 @@ argument. The encoding is done using a function from the ``urllib`` library
 *not* from ``urllib2``. ::
 
     import urllib
-    import urllib2  
+    import urllib2
 
     url = 'http://www.someserver.com/cgi-bin/register.cgi'
     values = {'name' : 'Michael Foord',
@@ -161,15 +161,15 @@ request as above, but identifies itself as a version of Internet
 Explorer [#]_. ::
 
     import urllib
-    import urllib2  
-    
+    import urllib2
+
     url = 'http://www.someserver.com/cgi-bin/register.cgi'
-    user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' 
+    user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
     values = {'name' : 'Michael Foord',
               'location' : 'Northampton',
               'language' : 'Python' }
     headers = { 'User-Agent' : user_agent }
-    
+
     data = urllib.urlencode(values)
     req = urllib2.Request(url, data, headers)
     response = urllib2.urlopen(req)
@@ -183,7 +183,7 @@ Handling Exceptions
 ===================
 
 *urlopen* raises :exc:`URLError` when it cannot handle a response (though as usual
-with Python APIs, builtin exceptions such as 
+with Python APIs, builtin exceptions such as
 :exc:`ValueError`, :exc:`TypeError` etc. may also
 be raised).
 
@@ -309,18 +309,18 @@ page returned. This means that as well as the code attribute, it also has read,
 geturl, and info, methods. ::
 
     >>> req = urllib2.Request('http://www.python.org/fish.html')
-    >>> try: 
+    >>> try:
     >>>     urllib2.urlopen(req)
     >>> except URLError, e:
     >>>     print e.code
     >>>     print e.read()
-    >>> 
+    >>>
     404
-    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
+    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
         "http://www.w3.org/TR/html4/loose.dtd">
-    <?xml-stylesheet href="./css/ht2html.css" 
+    <?xml-stylesheet href="./css/ht2html.css"
         type="text/css"?>
-    <html><head><title>Error 404: File Not Found</title> 
+    <html><head><title>Error 404: File Not Found</title>
     ...... etc...
 
 Wrapping it Up
@@ -372,7 +372,7 @@ Number 2
             print 'Error code: ', e.code
     else:
         # everything is fine
-        
+
 
 info and geturl
 ===============
@@ -443,7 +443,7 @@ error code) requesting authentication.  This specifies the authentication scheme
 and a 'realm'. The header looks like : ``Www-authenticate: SCHEME
 realm="REALM"``.
 
-e.g. :: 
+e.g. ::
 
     Www-authenticate: Basic realm="cPanel Users"
 
@@ -467,24 +467,24 @@ The top-level URL is the first URL that requires authentication. URLs "deeper"
 than the URL you pass to .add_password() will also match. ::
 
     # create a password manager
-    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()                        
+    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
 
     # Add the username and password.
-    # If we knew the realm, we could use it instead of ``None``.
+    # If we knew the realm, we could use it instead of None.
     top_level_url = "http://example.com/foo/"
     password_mgr.add_password(None, top_level_url, username, password)
 
-    handler = urllib2.HTTPBasicAuthHandler(password_mgr)                            
+    handler = urllib2.HTTPBasicAuthHandler(password_mgr)
 
     # create "opener" (OpenerDirector instance)
-    opener = urllib2.build_opener(handler)                       
+    opener = urllib2.build_opener(handler)
 
     # use the opener to fetch a URL
-    opener.open(a_url)      
+    opener.open(a_url)
 
     # Install the opener.
     # Now all calls to urllib2.urlopen use our opener.
-    urllib2.install_opener(opener)                               
+    urllib2.install_opener(opener)
 
 .. note::
 
@@ -540,7 +540,7 @@ you can set the default timeout globally for all sockets using ::
 
     # timeout in seconds
     timeout = 10
-    socket.setdefaulttimeout(timeout) 
+    socket.setdefaulttimeout(timeout)
 
     # this call to urllib2.urlopen now uses the default timeout
     # we have set in the socket module
@@ -557,7 +557,7 @@ Footnotes
 This document was reviewed and revised by John Lee.
 
 .. [#] For an introduction to the CGI protocol see
-       `Writing Web Applications in Python <http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html>`_. 
+       `Writing Web Applications in Python <http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html>`_.
 .. [#] Like Google for example. The *proper* way to use google from a program
        is to use `PyGoogle <http://pygoogle.sourceforge.net>`_ of course. See
        `Voidspace Google <http://www.voidspace.org.uk/python/recipebook.shtml#google>`_
@@ -574,6 +574,6 @@ This document was reviewed and revised by John Lee.
        is set to use the proxy, which urllib2 picks up on. In order to test
        scripts with a localhost server, I have to prevent urllib2 from using
        the proxy.
-.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe 
+.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
        <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_.
+
index 97c2267b7e6f1060e452247cbcc6f7cfff2b9f4b..6e0c815c4ef17ec90622aa1d5bbb5ac950c847dc 100644 (file)
@@ -88,7 +88,7 @@ they can be run as CGI if no better option is available.
    <http://wiki.python.org/moin/CgiScripts>`_ with some additional information
    about CGI in Python.
 
-   
+
 Simple script for testing CGI
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -386,7 +386,7 @@ compared with other web techniques.
 
    You might be interested in some WSGI-supporting modules already contained in
    the standard library, namely:
-    
+
    * :mod:`wsgiref` -- some tiny utilities and servers for WSGI
 
 
@@ -499,7 +499,7 @@ using these is a good idea.
    time in looking through the most popular ones.  Some frameworks have their
    own template engine or have a recommentation for one.  It's wise to use
    these.
-  
+
    Popular template engines include:
 
    * Mako
@@ -687,7 +687,7 @@ And that's still not everything.  The most up-to-date information can always be
 found in the Python wiki.
 
 .. seealso::
-    
+
    The Python wiki contains an extensive list of `web frameworks
    <http://wiki.python.org/moin/WebFrameworks>`_.
 
index 5ec718bf47d74d4d46dc8a175d7c6258ffb0a3cd..43c7ad13a9feb4c3dceb4950d8702af5b8d94be5 100644 (file)
-#\r
-# Module to allow spawning of processes on foreign host\r
-#\r
-# Depends on `multiprocessing` package -- tested with `processing-0.60`\r
-#\r
-# Copyright (c) 2006-2008, R Oudkerk\r
-# All rights reserved.\r
-#\r
-\r
-__all__ = ['Cluster', 'Host', 'get_logger', 'current_process']\r
-\r
-#\r
-# Imports\r
-#\r
-\r
-import sys\r
-import os\r
-import tarfile\r
-import shutil\r
-import subprocess\r
-import logging\r
-import itertools\r
-import Queue\r
-\r
-try:\r
-    import cPickle as pickle\r
-except ImportError:\r
-    import pickle\r
-\r
-from multiprocessing import Process, current_process, cpu_count\r
-from multiprocessing import util, managers, connection, forking, pool\r
-\r
-#\r
-# Logging\r
-#\r
-\r
-def get_logger():\r
-    return _logger\r
-\r
-_logger = logging.getLogger('distributing')\r
-_logger.propogate = 0\r
-\r
-_formatter = logging.Formatter(util.DEFAULT_LOGGING_FORMAT)\r
-_handler = logging.StreamHandler()\r
-_handler.setFormatter(_formatter)\r
-_logger.addHandler(_handler)\r
-\r
-info = _logger.info\r
-debug = _logger.debug\r
-\r
-#\r
-# Get number of cpus\r
-#\r
-\r
-try:\r
-    slot_count = cpu_count()\r
-except NotImplemented:\r
-    slot_count = 1\r
-        \r
-#\r
-# Manager type which spawns subprocesses\r
-#\r
-\r
-class HostManager(managers.SyncManager):\r
-    '''\r
-    Manager type used for spawning processes on a (presumably) foreign host\r
-    '''    \r
-    def __init__(self, address, authkey):\r
-        managers.SyncManager.__init__(self, address, authkey)\r
-        self._name = 'Host-unknown'\r
-\r
-    def Process(self, group=None, target=None, name=None, args=(), kwargs={}):\r
-        if hasattr(sys.modules['__main__'], '__file__'):\r
-            main_path = os.path.basename(sys.modules['__main__'].__file__)\r
-        else:\r
-            main_path = None\r
-        data = pickle.dumps((target, args, kwargs))\r
-        p = self._RemoteProcess(data, main_path)\r
-        if name is None:\r
-            temp = self._name.split('Host-')[-1] + '/Process-%s'\r
-            name = temp % ':'.join(map(str, p.get_identity()))\r
-        p.set_name(name)\r
-        return p\r
-\r
-    @classmethod\r
-    def from_address(cls, address, authkey):\r
-        manager = cls(address, authkey)\r
-        managers.transact(address, authkey, 'dummy')\r
-        manager._state.value = managers.State.STARTED\r
-        manager._name = 'Host-%s:%s' % manager.address\r
-        manager.shutdown = util.Finalize(\r
-            manager, HostManager._finalize_host,\r
-            args=(manager._address, manager._authkey, manager._name),\r
-            exitpriority=-10\r
-            )\r
-        return manager\r
-\r
-    @staticmethod\r
-    def _finalize_host(address, authkey, name):\r
-        managers.transact(address, authkey, 'shutdown')\r
-        \r
-    def __repr__(self):\r
-        return '<Host(%s)>' % self._name\r
-\r
-#\r
-# Process subclass representing a process on (possibly) a remote machine\r
-#\r
-\r
-class RemoteProcess(Process):\r
-    '''\r
-    Represents a process started on a remote host\r
-    '''\r
-    def __init__(self, data, main_path):\r
-        assert not main_path or os.path.basename(main_path) == main_path\r
-        Process.__init__(self)\r
-        self._data = data\r
-        self._main_path = main_path\r
-        \r
-    def _bootstrap(self):\r
-        forking.prepare({'main_path': self._main_path})\r
-        self._target, self._args, self._kwargs = pickle.loads(self._data)\r
-        return Process._bootstrap(self)\r
-        \r
-    def get_identity(self):\r
-        return self._identity\r
-\r
-HostManager.register('_RemoteProcess', RemoteProcess)\r
-\r
-#\r
-# A Pool class that uses a cluster\r
-#\r
-\r
-class DistributedPool(pool.Pool):\r
-    \r
-    def __init__(self, cluster, processes=None, initializer=None, initargs=()):\r
-        self._cluster = cluster\r
-        self.Process = cluster.Process\r
-        pool.Pool.__init__(self, processes or len(cluster),\r
-                           initializer, initargs)\r
-        \r
-    def _setup_queues(self):\r
-        self._inqueue = self._cluster._SettableQueue()\r
-        self._outqueue = self._cluster._SettableQueue()\r
-        self._quick_put = self._inqueue.put\r
-        self._quick_get = self._outqueue.get\r
-\r
-    @staticmethod\r
-    def _help_stuff_finish(inqueue, task_handler, size):\r
-        inqueue.set_contents([None] * size)\r
-\r
-#\r
-# Manager type which starts host managers on other machines\r
-#\r
-\r
-def LocalProcess(**kwds):\r
-    p = Process(**kwds)\r
-    p.set_name('localhost/' + p.name)\r
-    return p\r
-\r
-class Cluster(managers.SyncManager):\r
-    '''\r
-    Represents collection of slots running on various hosts.\r
-    \r
-    `Cluster` is a subclass of `SyncManager` so it allows creation of\r
-    various types of shared objects.\r
-    '''\r
-    def __init__(self, hostlist, modules):\r
-        managers.SyncManager.__init__(self, address=('localhost', 0))\r
-        self._hostlist = hostlist\r
-        self._modules = modules\r
-        if __name__ not in modules:\r
-            modules.append(__name__)\r
-        files = [sys.modules[name].__file__ for name in modules]\r
-        for i, file in enumerate(files):\r
-            if file.endswith('.pyc') or file.endswith('.pyo'):\r
-                files[i] = file[:-4] + '.py'\r
-        self._files = [os.path.abspath(file) for file in files]\r
-        \r
-    def start(self):\r
-        managers.SyncManager.start(self)\r
-        \r
-        l = connection.Listener(family='AF_INET', authkey=self._authkey)\r
-        \r
-        for i, host in enumerate(self._hostlist):\r
-            host._start_manager(i, self._authkey, l.address, self._files)\r
-\r
-        for host in self._hostlist:\r
-            if host.hostname != 'localhost':\r
-                conn = l.accept()\r
-                i, address, cpus = conn.recv()\r
-                conn.close()\r
-                other_host = self._hostlist[i]\r
-                other_host.manager = HostManager.from_address(address,\r
-                                                              self._authkey)\r
-                other_host.slots = other_host.slots or cpus\r
-                other_host.Process = other_host.manager.Process\r
-            else:\r
-                host.slots = host.slots or slot_count\r
-                host.Process = LocalProcess\r
-\r
-        self._slotlist = [\r
-            Slot(host) for host in self._hostlist for i in range(host.slots)\r
-            ]\r
-        self._slot_iterator = itertools.cycle(self._slotlist)\r
-        self._base_shutdown = self.shutdown\r
-        del self.shutdown\r
-        \r
-    def shutdown(self):\r
-        for host in self._hostlist:\r
-            if host.hostname != 'localhost':\r
-                host.manager.shutdown()\r
-        self._base_shutdown()\r
-        \r
-    def Process(self, group=None, target=None, name=None, args=(), kwargs={}):\r
-        slot = self._slot_iterator.next()\r
-        return slot.Process(\r
-            group=group, target=target, name=name, args=args, kwargs=kwargs\r
-            )\r
-\r
-    def Pool(self, processes=None, initializer=None, initargs=()):\r
-        return DistributedPool(self, processes, initializer, initargs)\r
-    \r
-    def __getitem__(self, i):\r
-        return self._slotlist[i]\r
-\r
-    def __len__(self):\r
-        return len(self._slotlist)\r
-\r
-    def __iter__(self):\r
-        return iter(self._slotlist)\r
-\r
-#\r
-# Queue subclass used by distributed pool\r
-#\r
-\r
-class SettableQueue(Queue.Queue):\r
-    def empty(self):\r
-        return not self.queue\r
-    def full(self):\r
-        return self.maxsize > 0 and len(self.queue) == self.maxsize\r
-    def set_contents(self, contents):\r
-        # length of contents must be at least as large as the number of\r
-        # threads which have potentially called get()\r
-        self.not_empty.acquire()\r
-        try:\r
-            self.queue.clear()\r
-            self.queue.extend(contents)\r
-            self.not_empty.notifyAll()\r
-        finally:\r
-            self.not_empty.release()\r
-            \r
-Cluster.register('_SettableQueue', SettableQueue)\r
-\r
-#\r
-# Class representing a notional cpu in the cluster\r
-#\r
-\r
-class Slot(object):\r
-    def __init__(self, host):\r
-        self.host = host\r
-        self.Process = host.Process\r
-\r
-#\r
-# Host\r
-#\r
-\r
-class Host(object):\r
-    '''\r
-    Represents a host to use as a node in a cluster.\r
-\r
-    `hostname` gives the name of the host.  If hostname is not\r
-    "localhost" then ssh is used to log in to the host.  To log in as\r
-    a different user use a host name of the form\r
-    "username@somewhere.org"\r
-\r
-    `slots` is used to specify the number of slots for processes on\r
-    the host.  This affects how often processes will be allocated to\r
-    this host.  Normally this should be equal to the number of cpus on\r
-    that host.\r
-    '''\r
-    def __init__(self, hostname, slots=None):\r
-        self.hostname = hostname\r
-        self.slots = slots\r
-        \r
-    def _start_manager(self, index, authkey, address, files):\r
-        if self.hostname != 'localhost':\r
-            tempdir = copy_to_remote_temporary_directory(self.hostname, files)\r
-            debug('startup files copied to %s:%s', self.hostname, tempdir)\r
-            p = subprocess.Popen(\r
-                ['ssh', self.hostname, 'python', '-c',\r
-                 '"import os; os.chdir(%r); '\r
-                 'from distributing import main; main()"' % tempdir],\r
-                stdin=subprocess.PIPE\r
-                )\r
-            data = dict(\r
-                name='BoostrappingHost', index=index,\r
-                dist_log_level=_logger.getEffectiveLevel(),\r
-                dir=tempdir, authkey=str(authkey), parent_address=address\r
-                )\r
-            pickle.dump(data, p.stdin, pickle.HIGHEST_PROTOCOL)\r
-            p.stdin.close()\r
-\r
-#\r
-# Copy files to remote directory, returning name of directory\r
-#\r
-\r
-unzip_code = '''"\r
-import tempfile, os, sys, tarfile\r
-tempdir = tempfile.mkdtemp(prefix='distrib-')\r
-os.chdir(tempdir)\r
-tf = tarfile.open(fileobj=sys.stdin, mode='r|gz')\r
-for ti in tf:\r
-    tf.extract(ti)\r
-print tempdir\r
-"'''\r
-\r
-def copy_to_remote_temporary_directory(host, files):\r
-    p = subprocess.Popen(\r
-        ['ssh', host, 'python', '-c', unzip_code],\r
-        stdout=subprocess.PIPE, stdin=subprocess.PIPE\r
-        )\r
-    tf = tarfile.open(fileobj=p.stdin, mode='w|gz')\r
-    for name in files:\r
-        tf.add(name, os.path.basename(name))\r
-    tf.close()\r
-    p.stdin.close()\r
-    return p.stdout.read().rstrip()\r
-\r
-#\r
-# Code which runs a host manager\r
-#\r
-\r
-def main():   \r
-    # get data from parent over stdin\r
-    data = pickle.load(sys.stdin)\r
-    sys.stdin.close()\r
-\r
-    # set some stuff\r
-    _logger.setLevel(data['dist_log_level'])\r
-    forking.prepare(data)\r
-    \r
-    # create server for a `HostManager` object\r
-    server = managers.Server(HostManager._registry, ('', 0), data['authkey'])\r
-    current_process()._server = server\r
-    \r
-    # report server address and number of cpus back to parent\r
-    conn = connection.Client(data['parent_address'], authkey=data['authkey'])\r
-    conn.send((data['index'], server.address, slot_count))\r
-    conn.close()\r
-    \r
-    # set name etc\r
-    current_process().set_name('Host-%s:%s' % server.address)\r
-    util._run_after_forkers()\r
-    \r
-    # register a cleanup function\r
-    def cleanup(directory):\r
-        debug('removing directory %s', directory)\r
-        shutil.rmtree(directory)\r
-        debug('shutting down host manager')\r
-    util.Finalize(None, cleanup, args=[data['dir']], exitpriority=0)\r
-    \r
-    # start host manager\r
-    debug('remote host manager starting in %s', data['dir'])\r
-    server.serve_forever()\r
+#
+# Module to allow spawning of processes on foreign host
+#
+# Depends on `multiprocessing` package -- tested with `processing-0.60`
+#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+
+__all__ = ['Cluster', 'Host', 'get_logger', 'current_process']
+
+#
+# Imports
+#
+
+import sys
+import os
+import tarfile
+import shutil
+import subprocess
+import logging
+import itertools
+import Queue
+
+try:
+    import cPickle as pickle
+except ImportError:
+    import pickle
+
+from multiprocessing import Process, current_process, cpu_count
+from multiprocessing import util, managers, connection, forking, pool
+
+#
+# Logging
+#
+
+def get_logger():
+    return _logger
+
+_logger = logging.getLogger('distributing')
+_logger.propogate = 0
+
+_formatter = logging.Formatter(util.DEFAULT_LOGGING_FORMAT)
+_handler = logging.StreamHandler()
+_handler.setFormatter(_formatter)
+_logger.addHandler(_handler)
+
+info = _logger.info
+debug = _logger.debug
+
+#
+# Get number of cpus
+#
+
+try:
+    slot_count = cpu_count()
+except NotImplemented:
+    slot_count = 1
+
+#
+# Manager type which spawns subprocesses
+#
+
+class HostManager(managers.SyncManager):
+    '''
+    Manager type used for spawning processes on a (presumably) foreign host
+    '''
+    def __init__(self, address, authkey):
+        managers.SyncManager.__init__(self, address, authkey)
+        self._name = 'Host-unknown'
+
+    def Process(self, group=None, target=None, name=None, args=(), kwargs={}):
+        if hasattr(sys.modules['__main__'], '__file__'):
+            main_path = os.path.basename(sys.modules['__main__'].__file__)
+        else:
+            main_path = None
+        data = pickle.dumps((target, args, kwargs))
+        p = self._RemoteProcess(data, main_path)
+        if name is None:
+            temp = self._name.split('Host-')[-1] + '/Process-%s'
+            name = temp % ':'.join(map(str, p.get_identity()))
+        p.set_name(name)
+        return p
+
+    @classmethod
+    def from_address(cls, address, authkey):
+        manager = cls(address, authkey)
+        managers.transact(address, authkey, 'dummy')
+        manager._state.value = managers.State.STARTED
+        manager._name = 'Host-%s:%s' % manager.address
+        manager.shutdown = util.Finalize(
+            manager, HostManager._finalize_host,
+            args=(manager._address, manager._authkey, manager._name),
+            exitpriority=-10
+            )
+        return manager
+
+    @staticmethod
+    def _finalize_host(address, authkey, name):
+        managers.transact(address, authkey, 'shutdown')
+
+    def __repr__(self):
+        return '<Host(%s)>' % self._name
+
+#
+# Process subclass representing a process on (possibly) a remote machine
+#
+
+class RemoteProcess(Process):
+    '''
+    Represents a process started on a remote host
+    '''
+    def __init__(self, data, main_path):
+        assert not main_path or os.path.basename(main_path) == main_path
+        Process.__init__(self)
+        self._data = data
+        self._main_path = main_path
+
+    def _bootstrap(self):
+        forking.prepare({'main_path': self._main_path})
+        self._target, self._args, self._kwargs = pickle.loads(self._data)
+        return Process._bootstrap(self)
+
+    def get_identity(self):
+        return self._identity
+
+HostManager.register('_RemoteProcess', RemoteProcess)
+
+#
+# A Pool class that uses a cluster
+#
+
+class DistributedPool(pool.Pool):
+
+    def __init__(self, cluster, processes=None, initializer=None, initargs=()):
+        self._cluster = cluster
+        self.Process = cluster.Process
+        pool.Pool.__init__(self, processes or len(cluster),
+                           initializer, initargs)
+
+    def _setup_queues(self):
+        self._inqueue = self._cluster._SettableQueue()
+        self._outqueue = self._cluster._SettableQueue()
+        self._quick_put = self._inqueue.put
+        self._quick_get = self._outqueue.get
+
+    @staticmethod
+    def _help_stuff_finish(inqueue, task_handler, size):
+        inqueue.set_contents([None] * size)
+
+#
+# Manager type which starts host managers on other machines
+#
+
+def LocalProcess(**kwds):
+    p = Process(**kwds)
+    p.set_name('localhost/' + p.name)
+    return p
+
+class Cluster(managers.SyncManager):
+    '''
+    Represents collection of slots running on various hosts.
+
+    `Cluster` is a subclass of `SyncManager` so it allows creation of
+    various types of shared objects.
+    '''
+    def __init__(self, hostlist, modules):
+        managers.SyncManager.__init__(self, address=('localhost', 0))
+        self._hostlist = hostlist
+        self._modules = modules
+        if __name__ not in modules:
+            modules.append(__name__)
+        files = [sys.modules[name].__file__ for name in modules]
+        for i, file in enumerate(files):
+            if file.endswith('.pyc') or file.endswith('.pyo'):
+                files[i] = file[:-4] + '.py'
+        self._files = [os.path.abspath(file) for file in files]
+
+    def start(self):
+        managers.SyncManager.start(self)
+
+        l = connection.Listener(family='AF_INET', authkey=self._authkey)
+
+        for i, host in enumerate(self._hostlist):
+            host._start_manager(i, self._authkey, l.address, self._files)
+
+        for host in self._hostlist:
+            if host.hostname != 'localhost':
+                conn = l.accept()
+                i, address, cpus = conn.recv()
+                conn.close()
+                other_host = self._hostlist[i]
+                other_host.manager = HostManager.from_address(address,
+                                                              self._authkey)
+                other_host.slots = other_host.slots or cpus
+                other_host.Process = other_host.manager.Process
+            else:
+                host.slots = host.slots or slot_count
+                host.Process = LocalProcess
+
+        self._slotlist = [
+            Slot(host) for host in self._hostlist for i in range(host.slots)
+            ]
+        self._slot_iterator = itertools.cycle(self._slotlist)
+        self._base_shutdown = self.shutdown
+        del self.shutdown
+
+    def shutdown(self):
+        for host in self._hostlist:
+            if host.hostname != 'localhost':
+                host.manager.shutdown()
+        self._base_shutdown()
+
+    def Process(self, group=None, target=None, name=None, args=(), kwargs={}):
+        slot = self._slot_iterator.next()
+        return slot.Process(
+            group=group, target=target, name=name, args=args, kwargs=kwargs
+            )
+
+    def Pool(self, processes=None, initializer=None, initargs=()):
+        return DistributedPool(self, processes, initializer, initargs)
+
+    def __getitem__(self, i):
+        return self._slotlist[i]
+
+    def __len__(self):
+        return len(self._slotlist)
+
+    def __iter__(self):
+        return iter(self._slotlist)
+
+#
+# Queue subclass used by distributed pool
+#
+
+class SettableQueue(Queue.Queue):
+    def empty(self):
+        return not self.queue
+    def full(self):
+        return self.maxsize > 0 and len(self.queue) == self.maxsize
+    def set_contents(self, contents):
+        # length of contents must be at least as large as the number of
+        # threads which have potentially called get()
+        self.not_empty.acquire()
+        try:
+            self.queue.clear()
+            self.queue.extend(contents)
+            self.not_empty.notifyAll()
+        finally:
+            self.not_empty.release()
+
+Cluster.register('_SettableQueue', SettableQueue)
+
+#
+# Class representing a notional cpu in the cluster
+#
+
+class Slot(object):
+    def __init__(self, host):
+        self.host = host
+        self.Process = host.Process
+
+#
+# Host
+#
+
+class Host(object):
+    '''
+    Represents a host to use as a node in a cluster.
+
+    `hostname` gives the name of the host.  If hostname is not
+    "localhost" then ssh is used to log in to the host.  To log in as
+    a different user use a host name of the form
+    "username@somewhere.org"
+
+    `slots` is used to specify the number of slots for processes on
+    the host.  This affects how often processes will be allocated to
+    this host.  Normally this should be equal to the number of cpus on
+    that host.
+    '''
+    def __init__(self, hostname, slots=None):
+        self.hostname = hostname
+        self.slots = slots
+
+    def _start_manager(self, index, authkey, address, files):
+        if self.hostname != 'localhost':
+            tempdir = copy_to_remote_temporary_directory(self.hostname, files)
+            debug('startup files copied to %s:%s', self.hostname, tempdir)
+            p = subprocess.Popen(
+                ['ssh', self.hostname, 'python', '-c',
+                 '"import os; os.chdir(%r); '
+                 'from distributing import main; main()"' % tempdir],
+                stdin=subprocess.PIPE
+                )
+            data = dict(
+                name='BoostrappingHost', index=index,
+                dist_log_level=_logger.getEffectiveLevel(),
+                dir=tempdir, authkey=str(authkey), parent_address=address
+                )
+            pickle.dump(data, p.stdin, pickle.HIGHEST_PROTOCOL)
+            p.stdin.close()
+
+#
+# Copy files to remote directory, returning name of directory
+#
+
+unzip_code = '''"
+import tempfile, os, sys, tarfile
+tempdir = tempfile.mkdtemp(prefix='distrib-')
+os.chdir(tempdir)
+tf = tarfile.open(fileobj=sys.stdin, mode='r|gz')
+for ti in tf:
+    tf.extract(ti)
+print tempdir
+"'''
+
+def copy_to_remote_temporary_directory(host, files):
+    p = subprocess.Popen(
+        ['ssh', host, 'python', '-c', unzip_code],
+        stdout=subprocess.PIPE, stdin=subprocess.PIPE
+        )
+    tf = tarfile.open(fileobj=p.stdin, mode='w|gz')
+    for name in files:
+        tf.add(name, os.path.basename(name))
+    tf.close()
+    p.stdin.close()
+    return p.stdout.read().rstrip()
+
+#
+# Code which runs a host manager
+#
+
+def main():
+    # get data from parent over stdin
+    data = pickle.load(sys.stdin)
+    sys.stdin.close()
+
+    # set some stuff
+    _logger.setLevel(data['dist_log_level'])
+    forking.prepare(data)
+
+    # create server for a `HostManager` object
+    server = managers.Server(HostManager._registry, ('', 0), data['authkey'])
+    current_process()._server = server
+
+    # report server address and number of cpus back to parent
+    conn = connection.Client(data['parent_address'], authkey=data['authkey'])
+    conn.send((data['index'], server.address, slot_count))
+    conn.close()
+
+    # set name etc
+    current_process().set_name('Host-%s:%s' % server.address)
+    util._run_after_forkers()
+
+    # register a cleanup function
+    def cleanup(directory):
+        debug('removing directory %s', directory)
+        shutil.rmtree(directory)
+        debug('shutting down host manager')
+    util.Finalize(None, cleanup, args=[data['dir']], exitpriority=0)
+
+    # start host manager
+    debug('remote host manager starting in %s', data['dir'])
+    server.serve_forever()
index 3f54b79b78de45d184534980d094317fb49f9bba..b1b94686cdfbda5d3c1c9ae9c73ad7c041050c85 100644 (file)
@@ -3,7 +3,7 @@
 .. _install-index:
 
 *****************************
-  Installing Python Modules  
+  Installing Python Modules
 *****************************
 
 :Author: Greg Ward
@@ -18,7 +18,7 @@
    Thus, I have to be sure to explain the basics at some point:
    sys.path and PYTHONPATH at least.  Should probably give pointers to
    other docs on "import site", PYTHONSTARTUP, PYTHONHOME, etc.
-   
+
    Finally, it might be useful to include all the material from my "Care
    and Feeding of a Python Installation" talk in here somewhere.  Yow!
 
@@ -268,7 +268,7 @@ at the prompt.  For example, on my Linux system, I type the three Python
 statements shown below, and get the output as shown, to find out my
 :file:`{prefix}` and :file:`{exec-prefix}`::
 
-   Python 2.4 (#26, Aug  7 2004, 17:19:02) 
+   Python 2.4 (#26, Aug  7 2004, 17:19:02)
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.prefix
@@ -587,11 +587,11 @@ value of ``sys.path``.   ::
    $ python
    Python 2.2 (#11, Oct  3 2002, 13:31:27)
    [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
-   Type ``help'', ``copyright'', ``credits'' or ``license'' for more information.
+   Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path
-   ['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', 
-    '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', 
+   ['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
+    '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
     '/usr/local/lib/python2.3/site-packages']
    >>>
 
index 8700fafe08ac3093f5fa07649baeb2d1ac6fb720..8014aedd56b75045902559212eca3e64dd715e9f 100644 (file)
@@ -43,15 +43,15 @@ This module provides the following class:
       Register *subclass* as a "virtual subclass" of this ABC. For
       example::
 
-       from abc import ABCMeta
+        from abc import ABCMeta
 
-       class MyABC:
-           __metaclass__ = ABCMeta
+        class MyABC:
+            __metaclass__ = ABCMeta
 
-       MyABC.register(tuple)
+        MyABC.register(tuple)
 
-       assert issubclass(tuple, MyABC)
-       assert isinstance((), MyABC)
+        assert issubclass(tuple, MyABC)
+        assert isinstance((), MyABC)
 
    You can also override this method in an abstract base class:
 
@@ -130,7 +130,7 @@ It also provides the following decorators:
    A decorator indicating abstract methods.
 
    Using this decorator requires that the class's metaclass is :class:`ABCMeta` or
-   is derived from it. 
+   is derived from it.
    A class that has a metaclass derived from :class:`ABCMeta`
    cannot be instantiated unless all of its abstract methods and
    properties are overridden.
@@ -166,7 +166,7 @@ It also provides the following decorators:
    A subclass of the built-in :func:`property`, indicating an abstract property.
 
    Using this function requires that the class's metaclass is :class:`ABCMeta` or
-   is derived from it. 
+   is derived from it.
    A class that has a metaclass derived from :class:`ABCMeta` cannot be
    instantiated unless all of its abstract methods and properties are overridden.
    The abstract properties can be called using any of the normal
index 7f7d7feeaf942488a48504078d24f7d3a26c7913..e3bb51a65c7b363c9d3582d4859859152a1b59e0 100644 (file)
@@ -17,7 +17,7 @@ samples in a file.  AIFF-C is a newer version of the format that includes the
 ability to compress the audio data.
 
 .. warning::
-   
+
    Some operations may only work under IRIX; these will raise :exc:`ImportError`
    when attempting to import the :mod:`cl` module, which is only available on IRIX.
 
index 4ce5098c19d53facabfe00dcc30bb7d2d4cf828e..12cec42dba734cabcc5302ce8d75735fa251f0fe 100644 (file)
@@ -6,7 +6,7 @@
    :platform: IRIX
    :synopsis: Audio functions on the SGI.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`al` module has been deprecated for removal in Python 3.0.
 
index e1a8ac093475ee922ea71fb5d6298e79a15ed473..5c1d5c45d03da2355ccdc1a878f70ecc0c99a929 100644 (file)
@@ -127,7 +127,7 @@ and classes for traversing abstract syntax trees:
    Parse an expression into an AST node.  Equivalent to ``compile(expr,
    filename, mode, ast.PyCF_ONLY_AST)``.
 
-   
+
 .. function:: literal_eval(node_or_string)
 
    Safely evaluate an expression node or a string containing a Python
@@ -191,7 +191,7 @@ and classes for traversing abstract syntax trees:
 
    A node visitor base class that walks the abstract syntax tree and calls a
    visitor function for every node found.  This function may return a value
-   which is forwarded by the `visit` method.
+   which is forwarded by the :meth:`visit` method.
 
    This class is meant to be subclassed, with the subclass adding visitor
    methods.
@@ -205,7 +205,7 @@ and classes for traversing abstract syntax trees:
    .. method:: generic_visit(node)
 
       This visitor calls :meth:`visit` on all children of the node.
-      
+
       Note that child nodes of nodes that have a custom visitor method won't be
       visited unless the visitor calls :meth:`generic_visit` or visits them
       itself.
@@ -220,11 +220,11 @@ and classes for traversing abstract syntax trees:
    A :class:`NodeVisitor` subclass that walks the abstract syntax tree and
    allows modification of nodes.
 
-   The `NodeTransformer` will walk the AST and use the return value of the
-   visitor methods to replace or remove the old node.  If the return value of
-   the visitor method is ``None``, the node will be removed from its location,
-   otherwise it is replaced with the return value.  The return value may be the
-   original node in which case no replacement takes place.
+   The :class:`NodeTransformer` will walk the AST and use the return value of
+   the visitor methods to replace or remove the old node.  If the return value
+   of the visitor method is ``None``, the node will be removed from its
+   location, otherwise it is replaced with the return value.  The return value
+   may be the original node in which case no replacement takes place.
 
    Here is an example transformer that rewrites all occurrences of name lookups
    (``foo``) to ``data['foo']``::
index 02bd75597f902d5fb30ba49ab0ef9538a8f92dae..8b7aa9e9e515168fb0fee8902b6c8d88a9b417c4 100644 (file)
@@ -265,7 +265,7 @@ sample and subtract the whole output sample from the input sample::
        in_test = inputdata[pos*2:]
        ipos, factor = audioop.findfit(in_test, out_test)
        # Optional (for better cancellation):
-       # factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)], 
+       # factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)],
        #              out_test)
        prefill = '\0'*(pos+ipos)*2
        postfill = '\0'*(len(inputdata)-len(prefill)-len(outputdata))
index 35ecd75aae8472680791890638d69083f4325be9..5916af4158413a1fd2119c7b380a7c389c5e8488 100644 (file)
@@ -5,10 +5,10 @@
 .. module:: Bastion
    :synopsis: Providing restricted access to objects.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`Bastion` module has been removed in Python 3.0.
-   
+
 .. moduleauthor:: Barry Warsaw <bwarsaw@python.org>
 
 
index 3041b7bc00f9931396f4827de215edb1e12f18b0..a74e14d68bf66818a3070dfc8a2603b5902fae77 100644 (file)
@@ -325,7 +325,7 @@ Finally, the module defines the following functions:
 
    Check whether we should break here, depending on the way the breakpoint *b*
    was set.
-   
+
    If it was set via line number, it checks if ``b.line`` is the same as the one
    in the frame also passed as argument.  If the breakpoint was set via function
    name, we have to check we are in the right frame (the right function) and if
@@ -335,7 +335,7 @@ Finally, the module defines the following functions:
 
    Determine if there is an effective (active) breakpoint at this line of code.
    Return breakpoint number or 0 if none.
-       
+
    Called only if we know there is a breakpoint at this location.  Returns the
    breakpoint that was triggered and a flag that indicates if it is ok to delete
    a temporary breakpoint.
index 52ff38a04042118946fce5c3759ab863a02ce2b3..f6aa6d7919bb64ca57487f02d786e89ba92543a6 100644 (file)
@@ -172,7 +172,7 @@ Example::
    >>> import bsddb
    >>> db = bsddb.btopen('/tmp/spam.db', 'c')
    >>> for i in range(10): db['%d'%i] = '%d'% (i*i)
-   ... 
+   ...
    >>> db['3']
    '9'
    >>> db.keys()
@@ -185,7 +185,7 @@ Example::
    ('9', '81')
    >>> db.set_location('2')
    ('2', '4')
-   >>> db.previous() 
+   >>> db.previous()
    ('1', '1')
    >>> for k, v in db.iteritems():
    ...     print k, v
index 7c93cec4d54d7bdae1dd917d09c963f83028e64c..7804c545054ecd2d8d4e81f25144fb069008754e 100644 (file)
@@ -93,7 +93,7 @@ Handling of compressed files is offered by the :class:`BZ2File` class.
       performance optimizations previously implemented in the :mod:`xreadlines`
       module.
 
-      .. deprecated:: 2.3 
+      .. deprecated:: 2.3
          This exists only for compatibility with the method by this name on
          :class:`file` objects, which is deprecated.  Use ``for line in file``
          instead.
index d0464e73d72c08922a6cc1e50a0b9801e738995e..00437649b265af0a98f23a0f5828e754cccd7edb 100644 (file)
@@ -6,8 +6,8 @@
    :platform: IRIX
    :synopsis: Interface to the CD-ROM on Silicon Graphics systems.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`cd` module has been deprecated for removal in Python 3.0.
 
index b9ea490abcb735690ae756bad8780c2af63c4f14..4469573ccf4229bdc56558df269d37eb911bba76 100644 (file)
@@ -70,9 +70,9 @@ Definition::
 
 .. function:: polar(x)
 
-   Convert a :class:`complex` from rectangular coordinates to polar 
+   Convert a :class:`complex` from rectangular coordinates to polar
    coordinates. The function returns a tuple with the two elements
-   *r* and *phi*. *r* is the distance from 0 and *phi* the phase 
+   *r* and *phi*. *r* is the distance from 0 and *phi* the phase
    angle.
 
    .. versionadded:: 2.6
index 456f6dd3c4c1ee23e89cc2f3262507e99cb00698..39981cab0d5c05cddb776522aa3d836289a0945f 100644 (file)
@@ -43,7 +43,7 @@ To do just the former:
    other value will cause :exc:`ValueError` to  be raised.
 
    .. warning::
-      
+
       It is possible (but not likely) that the parser stops parsing with a
       successful outcome before reaching the end of the source; in this case,
       trailing symbols may be ignored instead of causing an error.  For example,
index 40ec9e8f10bcea8626b386e61fe0fcb6336ae4c0..2725d68524be29ffcb4ee6f72343132da59cb996 100644 (file)
@@ -53,36 +53,36 @@ ABC                        Inherits               Abstract Methods        Mixin
 :class:`Hashable`                                 ``__hash__``
 :class:`Iterable`                                 ``__iter__``
 :class:`Iterator`          :class:`Iterable`      ``__next__``            ``__iter__``
-:class:`Sized`                                   ``__len__``
+:class:`Sized`                                    ``__len__``
 :class:`Callable`                                 ``__call__``
-                                                  
+
 :class:`Sequence`          :class:`Sized`,        ``__getitem__``         ``__contains__``. ``__iter__``, ``__reversed__``.
                            :class:`Iterable`,     and ``__len__``         ``index``, and ``count``
-                           :class:`Container`     
-                                                  
+                           :class:`Container`
+
 :class:`MutableSequence`   :class:`Sequence`      ``__getitem__``         Inherited Sequence methods and
                                                   ``__delitem__``,        ``append``, ``reverse``, ``extend``, ``pop``,
                                                   ``insert``,             ``remove``, and ``__iadd__``
                                                   and ``__len__``
-                                                  
+
 :class:`Set`               :class:`Sized`,        ``__len__``,            ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
                            :class:`Iterable`,     ``__iter__``, and       ``__gt__``, ``__ge__``, ``__and__``, ``__or__``
                            :class:`Container`     ``__contains__``        ``__sub__``, ``__xor__``, and ``isdisjoint``
-                                                  
+
 :class:`MutableSet`        :class:`Set`           ``add`` and             Inherited Set methods and
                                                   ``discard``             ``clear``, ``pop``, ``remove``, ``__ior__``,
                                                                           ``__iand__``, ``__ixor__``, and ``__isub__``
-                                                  
+
 :class:`Mapping`           :class:`Sized`,        ``__getitem__``,        ``__contains__``, ``keys``, ``items``, ``values``,
                            :class:`Iterable`,     ``__len__``. and        ``get``, ``__eq__``, and ``__ne__``
                            :class:`Container`     ``__iter__``
-                                                  
+
 :class:`MutableMapping`    :class:`Mapping`       ``__getitem__``         Inherited Mapping methods and
                                                   ``__setitem__``,        ``pop``, ``popitem``, ``clear``, ``update``,
                                                   ``__delitem__``,        and ``setdefault``
-                                                 ``__iter__``, and
+                                                  ``__iter__``, and
                                                   ``__len__``
-                                                  
+
 :class:`MappingView`       :class:`Sized`                                 ``__len__``
 :class:`KeysView`          :class:`MappingView`,                          ``__contains__``,
                            :class:`Set`                                   ``__iter__``
@@ -96,7 +96,7 @@ particular functionality, for example::
 
     size = None
     if isinstance(myvar, collections.Sized):
-       size = len(myvar)
+        size = len(myvar)
 
 Several of the ABCs are also useful as mixins that make it easier to develop
 classes supporting container APIs.  For example, to write a class supporting
@@ -549,8 +549,8 @@ Example:
                if kwds:
                    raise ValueError('Got unexpected field names: %r' % kwds.keys())
                return result
-   <BLANKLINE>            
-           def __getnewargs__(self): 
+   <BLANKLINE>
+           def __getnewargs__(self):
                return tuple(self)
    <BLANKLINE>
            x = property(itemgetter(0))
index e13f7fca02b2c2404f4fa4a39e7ce3fcac6233f2..0093518d50cc0bc2c127f015867e50fe59c4d2ef 100644 (file)
@@ -559,24 +559,24 @@ to create an instance from a repr, you must import the class names from the
    >>> import compiler
    >>> mod = compiler.parseFile("/tmp/doublelib.py")
    >>> mod
-   Module('This is an example module.\n\nThis is the docstring.\n', 
+   Module('This is an example module.\n\nThis is the docstring.\n',
           Stmt([Function(None, 'double', ['x'], [], 0,
-                         'Return twice the argument', 
+                         'Return twice the argument',
                          Stmt([Return(Mul((Name('x'), Const(2))))]))]))
    >>> from compiler.ast import *
-   >>> Module('This is an example module.\n\nThis is the docstring.\n', 
+   >>> Module('This is an example module.\n\nThis is the docstring.\n',
    ...    Stmt([Function(None, 'double', ['x'], [], 0,
-   ...                   'Return twice the argument', 
+   ...                   'Return twice the argument',
    ...                   Stmt([Return(Mul((Name('x'), Const(2))))]))]))
-   Module('This is an example module.\n\nThis is the docstring.\n', 
+   Module('This is an example module.\n\nThis is the docstring.\n',
           Stmt([Function(None, 'double', ['x'], [], 0,
-                         'Return twice the argument', 
+                         'Return twice the argument',
                          Stmt([Return(Mul((Name('x'), Const(2))))]))]))
    >>> mod.doc
    'This is an example module.\n\nThis is the docstring.\n'
    >>> for node in mod.node.nodes:
    ...     print node
-   ... 
+   ...
    Function(None, 'double', ['x'], [], 0, 'Return twice the argument',
             Stmt([Return(Mul((Name('x'), Const(2))))]))
    >>> func = mod.node.nodes[0]
index ec9aec2d1d5c4aba9b552c35174d418783e3573c..1de11b9a627109950e4b680d9ea8897c32c92e82 100644 (file)
@@ -11,9 +11,9 @@
 
 .. note::
 
-   The :mod:`ConfigParser` module has been renamed to `configparser` in Python
-   3.0.  The :term:`2to3` tool will automatically adapt imports when converting
-   your sources to 3.0.
+   The :mod:`ConfigParser` module has been renamed to :mod:`configparser` in
+   Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
+   converting your sources to 3.0.
 
 .. index::
    pair: .ini; file
index 022ac13aab9a185aeede3dfaf6d95105256b484a..f55d6c2f065cdbc4f38754b429cb802f8f54d98a 100644 (file)
@@ -733,7 +733,7 @@ accessed using the following methods:
 The :class:`Cookie` class also defines the following method:
 
 
-.. method:: Cookie.is_expired([now=:const:`None`])
+.. method:: Cookie.is_expired([now=None])
 
    True if cookie has passed the time at which the server requested it should
    expire.  If *now* is given (in seconds since the epoch), return whether the
index 43569449960aaeaa38cf0560041fe4cebb54f0ce..2f037c7e0e946959e03bed687282b05e19aa5bb7 100644 (file)
@@ -51,7 +51,7 @@ A simple example illustrating typical use::
        username = raw_input('Python login:')
        cryptedpasswd = pwd.getpwnam(username)[1]
        if cryptedpasswd:
-           if cryptedpasswd == 'x' or cryptedpasswd == '*': 
+           if cryptedpasswd == 'x' or cryptedpasswd == '*':
                raise "Sorry, currently no support for shadow passwords"
            cleartext = getpass.getpass()
            return crypt.crypt(cleartext, cryptedpasswd) == cryptedpasswd
index 2458b3cc3a40eddb49cff2a7c0b5ebab21964aa5..f19574b273f6d34c7b603bc3af129144ad9068fe 100644 (file)
@@ -76,7 +76,7 @@ The :mod:`csv` module defines the following functions:
    performed.
 
    A short usage example::
+
       >>> import csv
       >>> spamReader = csv.reader(open('eggs.csv'), delimiter=' ', quotechar='|')
       >>> for row in spamReader:
index 0e3733295ff0c1846cd40cbd05f5dac0e78698d1..a5a246714b31a490a208ff45b09b26e92b3d51e9 100644 (file)
@@ -1378,24 +1378,22 @@ it.
 The *mode* parameter can be used to specify how the library is loaded.  For
 details, consult the ``dlopen(3)`` manpage, on Windows, *mode* is ignored.
 
-The *use_errno* parameter, when set to True, enables a ctypes
-mechanism that allows to access the system `errno` error number in a
-safe way.  `ctypes` maintains a thread-local copy of the systems
-`errno` variable; if you call foreign functions created with
-`use_errno=True` then the `errno` value before the function call is
-swapped with the ctypes private copy, the same happens immediately
-after the function call.
-
-The function `ctypes.get_errno()` returns the value of the ctypes
-private copy, and the function `ctypes.set_errno(value)` changes the
-ctypes private copy to `value` and returns the former value.
-
-The *use_last_error* parameter, when set to True, enables the same
-mechanism for the Windows error code which is managed by the
-:func:`GetLastError` and :func:`SetLastError` Windows API functions;
-`ctypes.get_last_error()` and `ctypes.set_last_error(value)` are used
-to request and change the ctypes private copy of the windows error
-code.
+The *use_errno* parameter, when set to True, enables a ctypes mechanism that
+allows to access the system :data:`errno` error number in a safe way.
+:mod:`ctypes` maintains a thread-local copy of the systems :data:`errno`
+variable; if you call foreign functions created with ``use_errno=True`` then the
+:data:`errno` value before the function call is swapped with the ctypes private
+copy, the same happens immediately after the function call.
+
+The function :func:`ctypes.get_errno` returns the value of the ctypes private
+copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy
+to a new value and returns the former value.
+
+The *use_last_error* parameter, when set to True, enables the same mechanism for
+the Windows error code which is managed by the :func:`GetLastError` and
+:func:`SetLastError` Windows API functions; :func:`ctypes.get_last_error` and
+:func:`ctypes.set_last_error` are used to request and change the ctypes private
+copy of the windows error code.
 
 .. versionadded:: 2.6
    The ``use_last_error`` and ``use_errno`` optional parameters
@@ -1602,22 +1600,23 @@ type and the argument types of the function.
 .. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
 
    The returned function prototype creates functions that use the standard C
-   calling convention.  The function will release the GIL during the call.
-   If `use_errno` is set to True, the ctypes private copy of the system `errno`
-   variable is exchanged with the real `errno` value bafore and after the call;
-   `use_last_error` does the same for the Windows error code.
+   calling convention.  The function will release the GIL during the call.  If
+   *use_errno* is set to True, the ctypes private copy of the system
+   :data:`errno` variable is exchanged with the real :data:`errno` value bafore
+   and after the call; *use_last_error* does the same for the Windows error
+   code.
 
    .. versionchanged:: 2.6
-      The optional `use_errno` and `use_last_error` parameters were
-      added.
+      The optional *use_errno* and *use_last_error* parameters were added.
 
 
 .. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
 
    Windows only: The returned function prototype creates functions that use the
-   ``stdcall`` calling convention, except on Windows CE where :func:`WINFUNCTYPE`
-   is the same as :func:`CFUNCTYPE`.  The function will release the GIL during the
-   call. `use_errno` and `use_last_error` have the same meaning as above.
+   ``stdcall`` calling convention, except on Windows CE where
+   :func:`WINFUNCTYPE` is the same as :func:`CFUNCTYPE`.  The function will
+   release the GIL during the call.  *use_errno* and *use_last_error* have the
+   same meaning as above.
 
 
 .. function:: PYFUNCTYPE(restype, *argtypes)
@@ -1864,10 +1863,10 @@ Utility functions
 .. function:: find_library(name)
    :module: ctypes.util
 
-   Try to find a library and return a pathname.  `name` is the library name without
-   any prefix like `lib`, suffix like ``.so``, ``.dylib`` or version number (this
-   is the form used for the posix linker option :option:`-l`).  If no library can
-   be found, returns ``None``.
+   Try to find a library and return a pathname.  *name* is the library name
+   without any prefix like ``lib```, suffix like ``.so``, ``.dylib`` or version
+   number (this is the form used for the posix linker option :option:`-l`).  If
+   no library can be found, returns ``None``.
 
    The exact functionality is system dependent.
 
@@ -1905,14 +1904,14 @@ Utility functions
 .. function:: get_errno()
 
    Returns the current value of the ctypes-private copy of the system
-   `errno` variable in the calling thread.
+   :data:`errno` variable in the calling thread.
 
    .. versionadded:: 2.6
 
 .. function:: get_last_error()
 
    Windows only: returns the current value of the ctypes-private copy of the system
-   `LastError` variable in the calling thread.
+   :data:`LastError` variable in the calling thread.
 
    .. versionadded:: 2.6
 
@@ -1969,17 +1968,16 @@ Utility functions
 
 .. function:: set_errno(value)
 
-   Set the  current value of the ctypes-private copy of the system
-   `errno` variable in the calling thread to `value` and return the
-   previous value.
+   Set the current value of the ctypes-private copy of the system :data:`errno`
+   variable in the calling thread to *value* and return the previous value.
 
    .. versionadded:: 2.6
 
 .. function:: set_last_error(value)
 
-   Windows only: set the current value of the ctypes-private copy of
-   the system `LastError` variable in the calling thread to `value`
-   and return the previous value.
+   Windows only: set the current value of the ctypes-private copy of the system
+   :data:`LastError` variable in the calling thread to *value* and return the
+   previous value.
 
    .. versionadded:: 2.6
 
index 76b8470b3b4ab870f0f76b26c1aa2640aa212a76..570ed9efdc9e23e848f38015e6c5e2ee4f1640da 100644 (file)
@@ -266,10 +266,10 @@ efficient pickling, and in Boolean contexts, a :class:`timedelta` object is
 considered to be true if and only if it isn't equal to ``timedelta(0)``.
 
 Example usage:
-    
+
     >>> from datetime import timedelta
     >>> year = timedelta(days=365)
-    >>> another_year = timedelta(weeks=40, days=84, hours=23, 
+    >>> another_year = timedelta(weeks=40, days=84, hours=23,
     ...                          minutes=50, seconds=600)  # adds up to 365 days
     >>> year == another_year
     True
@@ -517,10 +517,10 @@ Example of counting days to an event::
     True
     >>> my_birthday = date(today.year, 6, 24)
     >>> if my_birthday < today:
-    ...     my_birthday = my_birthday.replace(year=today.year + 1) 
+    ...     my_birthday = my_birthday.replace(year=today.year + 1)
     >>> my_birthday
     datetime.date(2008, 6, 24)
-    >>> time_to_birthday = abs(my_birthday - today) 
+    >>> time_to_birthday = abs(my_birthday - today)
     >>> time_to_birthday.days
     202
 
@@ -1015,7 +1015,7 @@ Examples of working with datetime objects:
     >>> tt = dt.timetuple()
     >>> for it in tt:   # doctest: +SKIP
     ...     print it
-    ... 
+    ...
     2006    # year
     11      # month
     21      # day
@@ -1044,23 +1044,23 @@ Using datetime with tzinfo:
     ...     def __init__(self):         # DST starts last Sunday in March
     ...         d = datetime(dt.year, 4, 1)   # ends last Sunday in October
     ...         self.dston = d - timedelta(days=d.weekday() + 1)
-    ...         d = datetime(dt.year, 11, 1)    
+    ...         d = datetime(dt.year, 11, 1)
     ...         self.dstoff = d - timedelta(days=d.weekday() + 1)
     ...     def utcoffset(self, dt):
     ...         return timedelta(hours=1) + self.dst(dt)
-    ...     def dst(self, dt):              
+    ...     def dst(self, dt):
     ...         if self.dston <=  dt.replace(tzinfo=None) < self.dstoff:
     ...             return timedelta(hours=1)
     ...         else:
     ...             return timedelta(0)
     ...     def tzname(self,dt):
     ...          return "GMT +1"
-    ... 
+    ...
     >>> class GMT2(tzinfo):
     ...     def __init__(self):
-    ...         d = datetime(dt.year, 4, 1)  
+    ...         d = datetime(dt.year, 4, 1)
     ...         self.dston = d - timedelta(days=d.weekday() + 1)
-    ...         d = datetime(dt.year, 11, 1)    
+    ...         d = datetime(dt.year, 11, 1)
     ...         self.dstoff = d - timedelta(days=d.weekday() + 1)
     ...     def utcoffset(self, dt):
     ...         return timedelta(hours=1) + self.dst(dt)
@@ -1071,7 +1071,7 @@ Using datetime with tzinfo:
     ...             return timedelta(0)
     ...     def tzname(self,dt):
     ...         return "GMT +2"
-    ... 
+    ...
     >>> gmt1 = GMT1()
     >>> # Daylight Saving Time
     >>> dt1 = datetime(2006, 11, 21, 16, 30, tzinfo=gmt1)
@@ -1092,7 +1092,7 @@ Using datetime with tzinfo:
     datetime.datetime(2006, 6, 14, 13, 0, tzinfo=<GMT1 object at 0x...>)
     >>> dt2.utctimetuple() == dt3.utctimetuple()
     True
+
 
 
 .. _datetime-time:
@@ -1240,12 +1240,12 @@ Instance methods:
    return ``None`` or a string object.
 
 Example:
-    
+
     >>> from datetime import time, tzinfo
     >>> class GMT1(tzinfo):
     ...     def utcoffset(self, dt):
-    ...         return timedelta(hours=1) 
-    ...     def dst(self, dt):              
+    ...         return timedelta(hours=1)
+    ...     def dst(self, dt):
     ...         return timedelta(0)
     ...     def tzname(self,dt):
     ...         return "Europe/Prague"
@@ -1476,7 +1476,7 @@ Applications that can't bear such ambiguities should avoid using hybrid
 :class:`tzinfo` subclasses; there are no ambiguities when using UTC, or any
 other fixed-offset :class:`tzinfo` subclass (such as a class representing only
 EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
-    
+
 
 .. _strftime-behavior:
 
@@ -1521,7 +1521,7 @@ For an aware object:
 
 The full set of format codes supported varies across platforms, because Python
 calls the platform C library's :func:`strftime` function, and platform
-variations are common.  
+variations are common.
 
 The following is a list of all the format codes that the C standard (1989
 version) requires, and these work on all platforms with a standard C
index e14c4d13b259110aa1936c37dcce2f296fe4fb82..becac9823bcb4f256e001012795bf98f83429534 100644 (file)
@@ -328,7 +328,7 @@ Decimal objects
       infinity       ::=  'Infinity' | 'Inf'
       nan            ::=  'NaN' [digits] | 'sNaN' [digits]
       numeric-value  ::=  decimal-part [exponent-part] | infinity
-      numeric-string ::=  [sign] numeric-value | [sign] nan  
+      numeric-string ::=  [sign] numeric-value | [sign] nan
 
    If *value* is a :class:`tuple`, it should have three components, a sign
    (:const:`0` for positive or :const:`1` for negative), a :class:`tuple` of
@@ -947,7 +947,7 @@ In addition to the three supplied contexts, new contexts can be created with the
    * :const:`ROUND_HALF_EVEN` (to nearest with ties going to nearest even integer),
    * :const:`ROUND_HALF_UP` (to nearest with ties going away from zero), or
    * :const:`ROUND_UP` (away from zero).
-   * :const:`ROUND_05UP` (away from zero if last digit after rounding towards zero 
+   * :const:`ROUND_05UP` (away from zero if last digit after rounding towards zero
      would have been 0 or 5; otherwise towards zero)
 
    The *traps* and *flags* fields list any signals to be set. Generally, new
@@ -1168,7 +1168,7 @@ In addition to the three supplied contexts, new contexts can be created with the
 
    .. method:: logical_and(x, y)
 
-      Applies the logical operation `and` between each operand's digits.
+      Applies the logical operation *and* between each operand's digits.
 
 
    .. method:: logical_invert(x)
@@ -1178,12 +1178,12 @@ In addition to the three supplied contexts, new contexts can be created with the
 
    .. method:: logical_or(x, y)
 
-      Applies the logical operation `or` between each operand's digits.
+      Applies the logical operation *or* between each operand's digits.
 
 
    .. method:: logical_xor(x, y)
 
-      Applies the logical operation `xor` between each operand's digits.
+      Applies the logical operation *xor* between each operand's digits.
 
 
    .. method:: max(x, y)
@@ -1270,7 +1270,7 @@ In addition to the three supplied contexts, new contexts can be created with the
       that would be obtained by computing ``(x**y) % modulo`` with unbounded
       precision, but is computed more efficiently.  It is always exact.
 
-      .. versionchanged:: 2.6 
+      .. versionchanged:: 2.6
          ``y`` may now be nonintegral in ``x**y``.
          Stricter requirements for the three-argument version.
 
@@ -1294,8 +1294,8 @@ In addition to the three supplied contexts, new contexts can be created with the
 
    .. method:: remainder_near(x, y)
 
-      Returns `x - y * n`, where *n* is the integer nearest the exact value
-      of `x / y` (if the result is `0` then its sign will be the sign of *x*).
+      Returns ``x - y * n``, where *n* is the integer nearest the exact value
+      of ``x / y`` (if the result is 0 then its sign will be the sign of *x*).
 
 
    .. method:: rotate(x, y)
@@ -1412,7 +1412,7 @@ condition.
       sqrt(-x) and x > 0
       0 ** 0
       x ** (non-integer)
-      x ** Infinity      
+      x ** Infinity
 
 
 .. class:: Overflow
@@ -1515,7 +1515,7 @@ expanding the precision sufficiently to avoid loss of significance:
    Decimal('9.51111111')
    >>> u + (v + w)
    Decimal('9.51111111')
-   >>> 
+   >>>
    >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')
    >>> (u*v) + (u*w)
    Decimal('0.0060000')
@@ -1654,7 +1654,7 @@ to work with the :class:`Decimal` class::
 
        """
        q = Decimal(10) ** -places      # 2 places --> '0.01'
-       sign, digits, exp = value.quantize(q).as_tuple()  
+       sign, digits, exp = value.quantize(q).as_tuple()
        result = []
        digits = map(str, digits)
        build, next = result.append, digits.pop
@@ -1711,12 +1711,12 @@ to work with the :class:`Decimal` class::
        getcontext().prec += 2
        i, lasts, s, fact, num = 0, 0, 1, 1, 1
        while s != lasts:
-           lasts = s    
+           lasts = s
            i += 1
            fact *= i
-           num *= x     
-           s += num / fact   
-       getcontext().prec -= 2        
+           num *= x
+           s += num / fact
+       getcontext().prec -= 2
        return +s
 
    def cos(x):
@@ -1733,13 +1733,13 @@ to work with the :class:`Decimal` class::
        getcontext().prec += 2
        i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1
        while s != lasts:
-           lasts = s    
+           lasts = s
            i += 2
            fact *= i * (i-1)
            num *= x * x
            sign *= -1
-           s += num / fact * sign 
-       getcontext().prec -= 2        
+           s += num / fact * sign
+       getcontext().prec -= 2
        return +s
 
    def sin(x):
@@ -1756,13 +1756,13 @@ to work with the :class:`Decimal` class::
        getcontext().prec += 2
        i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1
        while s != lasts:
-           lasts = s    
+           lasts = s
            i += 2
            fact *= i * (i-1)
            num *= x * x
            sign *= -1
-           s += num / fact * sign 
-       getcontext().prec -= 2        
+           s += num / fact * sign
+       getcontext().prec -= 2
        return +s
 
 
@@ -1796,7 +1796,7 @@ the :const:`Inexact` trap is set, it is also useful for validation:
    >>> Decimal('3.214').quantize(TWOPLACES)
    Decimal('3.21')
 
-   >>> # Validate that a number does not exceed two places 
+   >>> # Validate that a number does not exceed two places
    >>> Decimal('3.21').quantize(TWOPLACES, context=Context(traps=[Inexact]))
    Decimal('3.21')
 
index f19156de9d2125be803ca0d9f2878337c963f1d1..addd813564ba077981b4087222609ca29f15fb75 100644 (file)
@@ -428,7 +428,7 @@ The :class:`SequenceMatcher` class has this constructor:
 
       .. XXX Explain why a dummy is used!
 
-      .. versionchanged:: 2.5 
+      .. versionchanged:: 2.5
          The guarantee that adjacent triples always describe non-adjacent blocks
          was implemented.
 
index d5907a65fccee3af31aeac09209740dc81a94066..71a8abea44c91488f69ffce28361b604b36ac559 100644 (file)
@@ -5,11 +5,11 @@
 .. module:: dircache
    :synopsis: Return directory listing, with cache mechanism.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`dircache` module has been removed in Python 3.0.
-   
-   
+
+
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
 
 
index 84a0c2598b5c57284d63507723a38ee629fc39d2..88e594755d44c3953204371075370355a9f2d98c 100644 (file)
@@ -755,7 +755,7 @@ the more significant byte last.
    opcode finds the keyword parameters first.  For each keyword argument, the value
    is on top of the key.  Below the keyword parameters, the positional parameters
    are on the stack, with the right-most parameter on top.  Below the parameters,
-   the function object to call is on the stack.  Pops all function arguments, and 
+   the function object to call is on the stack.  Pops all function arguments, and
    the function itself off the stack, and pushes the return value.
 
 
index ef8eb40e0af50f2318132189c9c2d339abdfc0c6..fdda2f9a8ba695a06c48bd5883e45726059a5747 100644 (file)
@@ -6,11 +6,11 @@
    :platform: Unix
    :synopsis: Call C functions in shared objects.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`dl` module has been removed in Python 3.0. Use the :mod:`ctypes`
     module instead.
-   
+
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
 
 The :mod:`dl` module defines an interface to the :cfunc:`dlopen` function, which
@@ -91,9 +91,9 @@ Dl objects, as returned by :func:`open` above, have the following methods:
    Return the pointer for the function named *name*, as a number, if it exists in
    the referenced shared object, otherwise ``None``. This is useful in code like::
 
-      >>> if a.sym('time'): 
+      >>> if a.sym('time'):
       ...     a.call('time')
-      ... else: 
+      ... else:
       ...     time.time()
 
    (Note that this function will return a non-zero number, as zero is the *NULL*
index 415a6825f929e2d1ec287c8dcec84a5279ab2563..8a0b01f35905ddaca0bd03b143bf0b20c1c35fb1 100644 (file)
@@ -2,7 +2,7 @@
 ----------------------------------------------------------
 
 .. module:: email.mime
-   :synopsis: Build MIME messages. 
+   :synopsis: Build MIME messages.
 
 
 Ordinarily, you get a message object structure by passing a file or some text to
@@ -57,14 +57,14 @@ Here are the classes:
 
 .. currentmodule:: email.mime.multipart
 
-.. class:: MIMEMultipart([subtype[, boundary[, _subparts[, _params]]]])
+.. class:: MIMEMultipart([_subtype[, boundary[, _subparts[, _params]]]])
 
    Module: :mod:`email.mime.multipart`
 
    A subclass of :class:`MIMEBase`, this is an intermediate base class for MIME
    messages that are :mimetype:`multipart`.  Optional *_subtype* defaults to
    :mimetype:`mixed`, but can be used to specify the subtype of the message.  A
-   :mailheader:`Content-Type` header of :mimetype:`multipart/`*_subtype* will be
+   :mailheader:`Content-Type` header of :mimetype:`multipart/_subtype` will be
    added to the message object.  A :mailheader:`MIME-Version` header will also be
    added.
 
index b3f7e61b6887886ddb1a19dff24032b2229cb4d3..269d8560f6eb50e769031cfd5c5023a20ee04b9b 100644 (file)
@@ -151,7 +151,7 @@ it is deleted when the output file is closed.  In-place filtering is disabled
 when standard input is read.
 
 .. warning::
-   
+
    The current implementation does not work for MS-DOS 8+3 filesystems.
 
 
index 02b13ff87e0b8f2bfeaad20f51dcd01119da5f6c..a5a426a140ef9fd3500c41d66673a428e25bee0d 100644 (file)
@@ -6,8 +6,8 @@
    :platform: IRIX
    :synopsis: FORMS library for applications with graphical user interfaces.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`fl` module has been deprecated for removal in Python 3.0.
 
@@ -484,8 +484,8 @@ FORMS objects have these data attributes; see the FORMS documentation:
    :platform: IRIX
    :synopsis: Constants used with the fl module.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`FL` module has been deprecated for removal in Python 3.0.
 
@@ -506,8 +506,8 @@ source for a complete list of the defined names.  Suggested use::
    :platform: IRIX
    :synopsis: Functions for loading stored FORMS designs.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`flp` module has been deprecated for removal in Python 3.0.
 
index 438135a45082a2d8e2dfacd281485ba81013e87f..e46506b65ef1866dfa32738a744b8f10154fa994 100644 (file)
@@ -6,7 +6,7 @@
    :platform: IRIX
    :synopsis: Font Manager interface for SGI workstations.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`fm` module has been deprecated for removal in Python 3.0.
 
index 29b29f4616f4ce2a3f8b5edfff54e9abe0a3ac1e..3448585609920d44f9c5d49f187155b824f6df78 100644 (file)
@@ -5,10 +5,10 @@
 .. module:: fpformat
    :synopsis: General floating point formatting functions.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`fpformat` module has been removed in Python 3.0.
-   
+
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
 
 
index aad62dd256d712849c237476775747f71de64556..36df11cc431236203d3d5e73a44ff627073579fe 100644 (file)
@@ -101,11 +101,11 @@ another rational number, or from a string.
 
 .. function:: gcd(a, b)
 
-   Return the greatest common divisor of the integers `a` and `b`.  If
-   either `a` or `b` is nonzero, then the absolute value of `gcd(a,
-   b)` is the largest integer that divides both `a` and `b`.  `gcd(a,b)`
-   has the same sign as `b` if `b` is nonzero; otherwise it takes the sign
-   of `a`.  `gcd(0, 0)` returns `0`.
+   Return the greatest common divisor of the integers *a* and *b*.  If either
+   *a* or *b* is nonzero, then the absolute value of ``gcd(a, b)`` is the
+   largest integer that divides both *a* and *b*.  ``gcd(a,b)`` has the same
+   sign as *b* if *b* is nonzero; otherwise it takes the sign of *a*.  ``gcd(0,
+   0)`` returns ``0``.
 
 
 .. seealso::
index 9b408dcdf7e073b5d2eafc11f1704acbf4dbe6cd..0977c91e52ed1704274d64cb476b43ff415d6ab9 100644 (file)
@@ -888,7 +888,7 @@ available.  They are listed here in alphabetical order.
    .. versionchanged:: 2.5
       Use *fget*'s docstring if no *doc* given.
 
-   .. versionchanged:: 2.6 
+   .. versionchanged:: 2.6
       The ``getter``, ``setter``, and ``deleter`` attributes were added.
 
 
@@ -1178,10 +1178,10 @@ available.  They are listed here in alphabetical order.
    single inheritance, "super" can be used to refer to parent classes without
    naming them explicitly, thus making the code more maintainable.  This use
    closely parallels the use of "super" in other programming languages.
-   
+
    The second use case is to support cooperative multiple inheritence in a
-   dynamic execution environment.  This use case is unique to Python and is 
-   not found in statically compiled languages or languages that only support 
+   dynamic execution environment.  This use case is unique to Python and is
+   not found in statically compiled languages or languages that only support
    single inheritance.  This makes in possible to implement "diamond diagrams"
    where multiple base classes implement the same method.  Good design dictates
    that this method have the same calling signature in every case (because the
@@ -1242,7 +1242,7 @@ available.  They are listed here in alphabetical order.
 
       >>> class X(object):
       ...     a = 1
-      ...     
+      ...
       >>> X = type('X', (object,), dict(a=1))
 
    .. versionadded:: 2.2
@@ -1397,7 +1397,7 @@ available.  They are listed here in alphabetical order.
 
    For example, the statement ``import spam`` results in bytecode resembling the
    following code::
-   
+
       spam = __import__('spam', globals(), locals(), [], -1)
 
    The statement ``import spam.ham`` results in this call::
index 22ad6682e8bd26f165e056315cfe12aa1222e65b..b95eb7910ff55cf47616ba07fcad5640b433006d 100644 (file)
@@ -648,10 +648,9 @@ translation until later.  A classic example is::
 
    animals = ['mollusk',
               'albatross',
-          'rat',
-          'penguin',
-          'python',
-          ]
+              'rat',
+              'penguin',
+              'python', ]
    # ...
    for a in animals:
        print a
@@ -666,10 +665,9 @@ Here is one way you can handle this situation::
 
    animals = [_('mollusk'),
               _('albatross'),
-          _('rat'),
-          _('penguin'),
-          _('python'),
-          ]
+              _('rat'),
+              _('penguin'),
+              _('python'), ]
 
    del _
 
@@ -692,10 +690,9 @@ Another way to handle this is with the following example::
 
    animals = [N_('mollusk'),
               N_('albatross'),
-          N_('rat'),
-          N_('penguin'),
-          N_('python'),
-          ]
+              N_('rat'),
+              N_('penguin'),
+              N_('python'), ]
 
    # ...
    for a in animals:
index 0afb1c887027ffd8a6ab965a3d8d6cd3626c9580..cbc175ad154802b52b4e0c2b977c67191111ec5d 100644 (file)
@@ -6,8 +6,8 @@
    :platform: IRIX
    :synopsis: Functions from the Silicon Graphics Graphics Library.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`gl` module has been deprecated for removal in Python 3.0.
 
@@ -166,8 +166,8 @@ Here is a tiny but complete example GL program in Python::
    :platform: IRIX
    :synopsis: Constants used with the gl module.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`DEVICE` module has been deprecated for removal in Python 3.0.
 
@@ -184,8 +184,8 @@ module source file for details.
    :platform: IRIX
    :synopsis: Constants used with the gl module.
    :deprecated:
-   
-   
+
+
 .. deprecated:: 2.6
     The :mod:`GL` module has been deprecated for removal in Python 3.0.
 
index 86be3cdd94d368ce5e489b3baf923d0a1aa9e9d3..c6f9ef82bd3182d2242a43a947b310b1c26cafac 100644 (file)
@@ -7,7 +7,7 @@
 This module provides a simple interface to compress and decompress files just
 like the GNU programs :program:`gzip` and :program:`gunzip` would.
 
-The data compression is provided by the :mod:``zlib`` module.
+The data compression is provided by the :mod:`zlib` module.
 
 The :mod:`gzip` module provides the :class:`GzipFile` class which is modeled
 after Python's File Object. The :class:`GzipFile` class reads and writes
index 2190b8057e05826365250276c777d671e26d8338..bf7e3c4cd260675f1fb342486b8d759026fbff70 100644 (file)
@@ -102,7 +102,7 @@ Using a heap to insert items at the correct place in a priority queue:
    H
    N
 
-   
+
 The module also offers three general purpose functions based on heaps.
 
 
index 0fa518e7914e6bb74a9f86c391ae02d53fec8836..f6ed5643e5a1547f1df012d08ca6abb0851153b2 100644 (file)
@@ -4,7 +4,7 @@
 .. module:: htmllib
    :synopsis: A parser for HTML documents.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`htmllib` module has been removed in Python 3.0.
 
index 65101fce26c33efbf0d5df8df05ded7b8f90f1d7..413750fda54e0bd9a1e751c2242f2916400f0899 100644 (file)
@@ -230,7 +230,7 @@ Python syntax colors:
    Keywords
       orange
 
-   Strings 
+   Strings
       green
 
    Comments
index 758d23ca6845d6880ac5e4c64278c5c771170795..ceef0c70d0c4a02afdf3834f5e5e86df8569ea4e 100644 (file)
@@ -5,7 +5,7 @@
 .. module:: imageop
    :synopsis: Manipulate raw image data.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`imageop` module has been removed in Python 3.0.
 
index 97854532fab7feb9a520fac590d016e98fb835ab..84ede95b28be8c790debddf331fe0fda8b04b122 100644 (file)
@@ -6,7 +6,7 @@
    :platform: IRIX
    :synopsis: Support for SGI imglib files.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`imgfile` module has been deprecated for removal in Python 3.0.
 
index 25d5f16dbae8ce0b20bfac4501b371bf650a350d..86407be21c85424f116998df6a02082272c5b7f2 100644 (file)
@@ -215,7 +215,7 @@ I/O Base Classes
    .. method:: close()
 
       Flush and close this stream. This method has no effect if the file is
-      already closed. Once the file is closed, any operation on the file 
+      already closed. Once the file is closed, any operation on the file
       (e.g. reading or writing) will raise an :exc:`IOError`. The internal
       file descriptor isn't closed if *closefd* was False.
 
@@ -629,7 +629,7 @@ Text I/O
    .. attribute:: line_buffering
 
       Whether line buffering is enabled.
-   
+
 
 .. class:: StringIO([initial_value[, encoding[, errors[, newline]]]])
 
index 348c2648807859fa9e65690ce3fa43463eb7d817..67646c66af0be980b1efd993e4524a65b7595bfb 100644 (file)
@@ -76,7 +76,7 @@ loops that truncate the stream.
 
 .. function:: itertools.chain.from_iterable(iterable)
 
-   Alternate constructor for :func:`chain`.  Gets chained inputs from a 
+   Alternate constructor for :func:`chain`.  Gets chained inputs from a
    single iterable argument that is evaluated lazily.  Equivalent to::
 
       @classmethod
@@ -93,9 +93,9 @@ loops that truncate the stream.
 
    Return *r* length subsequences of elements from the input *iterable*.
 
-   Combinations are emitted in lexicographic sort order.  So, if the 
+   Combinations are emitted in lexicographic sort order.  So, if the
    input *iterable* is sorted, the combination tuples will be produced
-   in sorted order.  
+   in sorted order.
 
    Elements are treated as unique based on their position, not on their
    value.  So if the input elements are unique, there will be no repeat
@@ -314,7 +314,7 @@ loops that truncate the stream.
           for i, element in enumerate(iterable):
               if i == nexti:
                   yield element
-                  nexti = it.next()          
+                  nexti = it.next()
 
    If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
    then the step defaults to one.
@@ -380,12 +380,12 @@ loops that truncate the stream.
    Return successive *r* length permutations of elements in the *iterable*.
 
    If *r* is not specified or is ``None``, then *r* defaults to the length
-   of the *iterable* and all possible full-length permutations 
+   of the *iterable* and all possible full-length permutations
    are generated.
 
-   Permutations are emitted in lexicographic sort order.  So, if the 
+   Permutations are emitted in lexicographic sort order.  So, if the
    input *iterable* is sorted, the permutation tuples will be produced
-   in sorted order.  
+   in sorted order.
 
    Elements are treated as unique based on their position, not on their
    value.  So if the input elements are unique, there will be no repeat
@@ -416,7 +416,7 @@ loops that truncate the stream.
                 else:
                     return
 
-   The code for :func:`permutations` can be also expressed as a subsequence of 
+   The code for :func:`permutations` can be also expressed as a subsequence of
    :func:`product`, filtered to exclude entries with repeated elements (those
    from the same position in the input pool)::
 
@@ -547,7 +547,7 @@ can be combined.
 
 .. doctest::
 
-   # Show a dictionary sorted and grouped by value
+   >>> # Show a dictionary sorted and grouped by value
    >>> from operator import itemgetter
    >>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
    >>> di = sorted(d.iteritems(), key=itemgetter(1))
@@ -558,13 +558,13 @@ can be combined.
    2 ['b', 'd', 'f']
    3 ['g']
 
-   # Find runs of consecutive numbers using groupby.  The key to the solution
-   # is differencing with a range so that consecutive numbers all appear in
-   # same group.
+   >>> # Find runs of consecutive numbers using groupby.  The key to the solution
+   >>> # is differencing with a range so that consecutive numbers all appear in
+   >>> # same group.
    >>> data = [ 1,  4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
    >>> for k, g in groupby(enumerate(data), lambda (i,x):i-x):
    ...     print map(itemgetter(1), g)
-   ... 
+   ...
    [1]
    [4, 5, 6]
    [10]
@@ -691,7 +691,7 @@ which incur interpreter overhead.
     def unique_everseen(iterable, key=None):
         "List unique elements, preserving order. Remember all elements ever seen."
         # unique_everseen('AAAABBBCCDAABBB') --> A B C D
-        # unique_everseen('ABBCcAD', str.lower) --> A B C D    
+        # unique_everseen('ABBCcAD', str.lower) --> A B C D
         seen = set()
         seen_add = seen.add
         if key is None:
index 5cc649f5dc440f47f647c06fc8674b1f8d49473e..98497adf8a37eaaffad9310eaa8fa50db4362f0a 100644 (file)
@@ -6,7 +6,7 @@
    :platform: IRIX
    :synopsis: Read and write image files in compressed JPEG format.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`jpeg` module has been deprecated for removal in Python 3.0.
 
index cf6138ed3fcdd1bfbfca487df1515f32eba63a99..8a644af823bc147346b5a023ab3b9ace393d1039 100644 (file)
@@ -14,7 +14,7 @@ syntax (ECMA-262 3rd edition) used as a lightweight data interchange format.
 :mod:`marshal` and :mod:`pickle` modules.
 
 Encoding basic Python object hierarchies::
-    
+
     >>> import json
     >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
     '["foo", {"bar": ["baz", null, 1.0, 2]}]'
@@ -43,12 +43,12 @@ Pretty printing::
     >>> import json
     >>> print json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
     {
-        "4": 5, 
+        "4": 5,
         "6": 7
     }
 
 Decoding JSON::
-    
+
     >>> import json
     >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
     [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
@@ -66,7 +66,7 @@ Specializing JSON object decoding::
     ...     if '__complex__' in dct:
     ...         return complex(dct['real'], dct['imag'])
     ...     return dct
-    ... 
+    ...
     >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}',
     ...     object_hook=as_complex)
     (1+2j)
@@ -75,26 +75,26 @@ Specializing JSON object decoding::
     Decimal('1.1')
 
 Extending :class:`JSONEncoder`::
-    
+
     >>> import json
     >>> class ComplexEncoder(json.JSONEncoder):
     ...     def default(self, obj):
     ...         if isinstance(obj, complex):
     ...             return [obj.real, obj.imag]
     ...         return json.JSONEncoder.default(self, obj)
-    ... 
+    ...
     >>> dumps(2 + 1j, cls=ComplexEncoder)
     '[2.0, 1.0]'
     >>> ComplexEncoder().encode(2 + 1j)
     '[2.0, 1.0]'
     >>> list(ComplexEncoder().iterencode(2 + 1j))
     ['[', '2.0', ', ', '1.0', ']']
-    
+
 
 .. highlight:: none
 
 Using json.tool from the shell to validate and pretty-print::
-    
+
     $ echo '{"json":"obj"}' | python -mjson.tool
     {
         "json": "obj"
@@ -104,7 +104,7 @@ Using json.tool from the shell to validate and pretty-print::
 
 .. highlight:: python
 
-.. note:: 
+.. note::
 
    The JSON produced by this module's default settings is a subset of
    YAML, so it may be used as a serializer for that as well.
@@ -152,7 +152,7 @@ Basic Usage
    *default(obj)* is a function that should return a serializable version of
    *obj* or raise :exc:`TypeError`.  The default simply raises :exc:`TypeError`.
 
-   To use a custom :class:`JSONEncoder`` subclass (e.g. one that overrides the
+   To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
    :meth:`default` method to serialize additional types), specify it with the
    *cls* kwarg.
 
@@ -368,7 +368,7 @@ Encoders and decoders
 
       For example, to support arbitrary iterators, you could implement default
       like this::
-            
+
          def default(self, o):
             try:
                 iterable = iter(o)
@@ -392,6 +392,6 @@ Encoders and decoders
 
       Encode the given object, *o*, and yield each string representation as
       available.  For example::
-            
+
             for chunk in JSONEncoder().iterencode(bigobject):
                 mysocket.write(chunk)
index 3dfefa2657fe4c719fb5710dde7676233c1b97b2..750fb2e1a329af60b5a36f0aec34b135a3e52be4 100644 (file)
@@ -494,7 +494,7 @@ Example::
    >>> import locale
    >>> loc = locale.getlocale() # get current locale
    >>> locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform
-   >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut 
+   >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
    >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
    >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
    >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale
index 7376de14043ba95c4207f28da2172310863def43..526fb3ce12e5558dcebeb448290f8c090c87dffc 100644 (file)
@@ -82,7 +82,7 @@ Note the capitalization of the module name; this is a historical artifact.
    parameter can be a pathname or an ``FSSpec`` or  ``FSRef`` object.
 
    .. note::
-      
+
       It is not possible to use an ``FSSpec`` in 64-bit mode.
 
 
@@ -93,7 +93,7 @@ Note the capitalization of the module name; this is a historical artifact.
    strings.
 
    .. note::
-      
+
       It is not possible to use an ``FSSpec`` in 64-bit mode.
 
 .. function:: openrf(name [, mode])
index 0a8c6dfeafe157e64554100472bb5971e0d5bde0..01d3f4b8887f50a38c9e50c945aba6fde193aa57 100644 (file)
@@ -1686,7 +1686,7 @@ due to malformed messages in the mailbox::
                # that's better than losing a message completely.
                box.lock()
                box.add(message)
-               box.flush()         
+               box.flush()
                box.unlock()
 
                # Remove original message
index 4f5b16ac869a5c511c75a54348c1c9c82c1b78d6..a9d6ea823f445d7e3fd30b8cf82e578dbb8a1b31 100644 (file)
@@ -45,7 +45,7 @@ themselves supported; and recursive lists and dictionaries should not be written
 (they will cause infinite loops).
 
 .. warning::
-   
+
    On machines where C's ``long int`` type has more than 32 bits (such as the
    DEC Alpha), it is possible to create plain Python integers that are longer
    than 32 bits. If such an integer is marshaled and read back in on a machine
index 39fde8217117c660ccb8592685c61adc9b2ccae4..b33c597d7bdeda6e584f439f19614d0a016c3a79 100644 (file)
@@ -109,7 +109,7 @@ Number-theoretic and representation functions
 .. function:: isnan(x)
 
    Checks if the float *x* is a NaN (not a number). NaNs are part of the
-   IEEE 754 standards. Operation like but not limited to ``inf * 0``, 
+   IEEE 754 standards. Operation like but not limited to ``inf * 0``,
    ``inf / inf`` or any operation involving a NaN, e.g. ``nan * 1``, return
    a NaN.
 
index 2a6a2dbd7df3f95ea29d10b0c09a4a91dfcb3c86..2aab1dc083b7a18eb66d7420d31d237ff41dc16c 100644 (file)
@@ -4,7 +4,7 @@
 .. module:: mhlib
    :synopsis: Manipulate MH mailboxes from Python.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`mhlib` module has been removed in Python 3.0. Use the
     :mod:`mailbox` instead.
index 8b4685ce6bd6822f906feeb8a3a8efa302faee2b..09ec73b094520320e5a4fe253d6dcab721fec457 100644 (file)
@@ -93,7 +93,7 @@ memory but does not update the underlying file.
    will be relative to the offset from the beginning of the file. *offset*
    defaults to 0.  *offset* must be a multiple of the PAGESIZE or
    ALLOCATIONGRANULARITY.
-   
+
    This example shows a simple way of using :class:`mmap`::
 
       import mmap
index 47d63b52d7e58c928ba98e71f1cf922b366b1b58..4537be899974de3a3f2cc7e01c6da408620a0727 100644 (file)
@@ -18,7 +18,7 @@ documentation.
 
 The module implements both the normal and wide char variants of the console I/O
 api. The normal API deals only with ASCII characters and is of limited use
-for internationalized applications. The wide char API should be used where 
+for internationalized applications. The wide char API should be used where
 ever possible
 
 .. _msvcrt-files:
@@ -98,13 +98,13 @@ Console I/O
    return the keycode.  The :kbd:`Control-C` keypress cannot be read with this
    function.
 
-   
+
 .. function:: getwch()
 
    Wide char variant of :func:`getch`, returning a Unicode value.
-   
+
    .. versionadded:: 2.6
-   
+
 
 .. function:: getche()
 
@@ -115,7 +115,7 @@ Console I/O
 .. function:: getwche()
 
    Wide char variant of :func:`getche`, returning a Unicode value.
-   
+
    .. versionadded:: 2.6
 
 
@@ -123,24 +123,24 @@ Console I/O
 
    Print the character *char* to the console without buffering.
 
-   
+
 .. function:: putwch(unicode_char)
 
    Wide char variant of :func:`putch`, accepting a Unicode value.
-   
+
    .. versionadded:: 2.6
-   
+
 
 .. function:: ungetch(char)
 
    Cause the character *char* to be "pushed back" into the console buffer; it will
    be the next character read by :func:`getch` or :func:`getche`.
 
-   
+
 .. function:: ungetwch(unicode_char)
 
    Wide char variant of :func:`ungetch`, accepting a Unicode value.
-   
+
    .. versionadded:: 2.6
 
 
index 6f4a3f1bf14667fe941e112da22e0adfb0bcd289..72cf5101a96fffba6b5c7a85ba537f47ed37a580 100644 (file)
@@ -21,9 +21,9 @@ Windows.
 .. warning::
 
     Some of this package's functionality requires a functioning shared semaphore
-    implementation on the host operating system. Without one, the 
-    :mod:`multiprocessing.synchronize` module will be disabled, and attempts to 
-    import it will result in an :exc:`ImportError`. See 
+    implementation on the host operating system. Without one, the
+    :mod:`multiprocessing.synchronize` module will be disabled, and attempts to
+    import it will result in an :exc:`ImportError`. See
     :issue:`3770` for additional information.
 
 .. note::
@@ -37,8 +37,8 @@ Windows.
         >>> from multiprocessing import Pool
         >>> p = Pool(5)
         >>> def f(x):
-        ...    return x*x
-        ... 
+        ...     return x*x
+        ...
         >>> p.map(f, [1,2,3])
         Process PoolWorker-1:
         Process PoolWorker-2:
@@ -77,11 +77,11 @@ To show the individual process IDs involved, here is an expanded example::
         print 'module name:', __name__
         print 'parent process:', os.getppid()
         print 'process id:', os.getpid()
-    
+
     def f(name):
         info('function f')
         print 'hello', name
-    
+
     if __name__ == '__main__':
         info('main line')
         p = Process(target=f, args=('bob',))
@@ -109,12 +109,12 @@ processes:
       def f(q):
           q.put([42, None, 'hello'])
 
-       if __name__ == '__main__':
-           q = Queue()
-           p = Process(target=f, args=(q,))
-           p.start()
-           print q.get()    # prints "[42, None, 'hello']"
-           p.join()
+      if __name__ == '__main__':
+          q = Queue()
+          p = Process(target=f, args=(q,))
+          p.start()
+          print q.get()    # prints "[42, None, 'hello']"
+          p.join()
 
    Queues are thread and process safe.
 
@@ -543,7 +543,7 @@ For an example of the usage of queues for interprocess communication see
 
    .. method:: put(item[, block[, timeout]])
 
-      Put item into the queue.  If the optional argument *block* is ``True`` 
+      Put item into the queue.  If the optional argument *block* is ``True``
       (the default) and *timeout* is ``None`` (the default), block if necessary until
       a free slot is available.  If *timeout* is a positive number, it blocks at
       most *timeout* seconds and raises the :exc:`Queue.Full` exception if no
@@ -858,7 +858,7 @@ object -- see :ref:`multiprocessing-managers`.
    acceptable.  If *block* is ``True`` and *timeout* is not ``None`` then it
    specifies a timeout in seconds.  If *block* is ``False`` then *timeout* is
    ignored.
-   
+
    Note that on OS/X ``sem_timedwait`` is unsupported, so timeout arguments
    for these will be ignored.
 
@@ -1135,22 +1135,22 @@ their parent process exits.  The manager classes are defined in the
       server process which is using the given address and authentication key.
 
    .. method:: get_server()
-      
+
       Returns a :class:`Server` object which represents the actual server under
-      the control of the Manager. The :class:`Server` object supports the 
-      :meth:`serve_forever` method::
-      
-       >>> from multiprocessing.managers import BaseManager
-       >>> m = BaseManager(address=('', 50000), authkey='abc'))
-       >>> server = m.get_server()
-       >>> s.serve_forever()
-       
-       :class:`Server` additionally have an :attr:`address` attribute.
+      the control of the Manager. The :class:`Server` object supports the
+      :meth:`serve_forever` method:
+
+      >>> from multiprocessing.managers import BaseManager
+      >>> m = BaseManager(address=('', 50000), authkey='abc'))
+      >>> server = m.get_server()
+      >>> s.serve_forever()
+
+      :class:`Server` additionally have an :attr:`address` attribute.
 
    .. method:: connect()
-   
-      Connect a local manager object to a remote manager process::
-      
+
+      Connect a local manager object to a remote manager process:
+
       >>> from multiprocessing.managers import BaseManager
       >>> m = BaseManager(address='127.0.0.1', authkey='abc))
       >>> m.connect()
@@ -1295,7 +1295,7 @@ Customized managers
 >>>>>>>>>>>>>>>>>>>
 
 To create one's own manager, one creates a subclass of :class:`BaseManager` and
-use the :meth:`~BaseManager.resgister` classmethod to register new types or
+use the :meth:`~BaseManager.register` classmethod to register new types or
 callables with the manager class.  For example::
 
    from multiprocessing.managers import BaseManager
@@ -1360,7 +1360,7 @@ Another client can also use it::
    >>> queue.get()
    'hello'
 
-Local processes can also access that queue, using the code from above on the 
+Local processes can also access that queue, using the code from above on the
 client to access it remotely::
 
     >>> from multiprocessing import Process, Queue
@@ -1371,12 +1371,12 @@ client to access it remotely::
     ...         super(Worker, self).__init__()
     ...     def run(self):
     ...         self.q.put('local hello')
-    ... 
+    ...
     >>> queue = Queue()
     >>> w = Worker(queue)
     >>> w.start()
     >>> class QueueManager(BaseManager): pass
-    ... 
+    ...
     >>> QueueManager.register('get_queue', callable=lambda: queue)
     >>> m = QueueManager(address=('', 50000), authkey='abracadabra')
     >>> s = m.get_server()
@@ -1811,7 +1811,7 @@ Address Formats
 
 * An ``'AF_PIPE'`` address is a string of the form
    :samp:`r'\\\\.\\pipe\\{PipeName}'`.  To use :func:`Client` to connect to a named
-   pipe on a remote computer called ServerName* one should use an address of the
+   pipe on a remote computer called *ServerName* one should use an address of the
    form :samp:`r'\\\\{ServerName}\\pipe\\{PipeName}'`` instead.
 
 Note that any string beginning with two backslashes is assumed by default to be
@@ -2120,7 +2120,7 @@ Some simple benchmarks comparing :mod:`multiprocessing` with :mod:`threading`:
 .. literalinclude:: ../includes/mp_benchmarks.py
 
 An example/demo of how to use the :class:`managers.SyncManager`, :class:`Process`
-and others to build a system which can distribute processes and work via a 
+and others to build a system which can distribute processes and work via a
 distributed queue to a "cluster" of machines on a network, accessible via SSH.
 You will need to have private key authentication for all hosts configured for
 this to work.
index 480c888c79d0fb2dcc95d59053beb69bc85ab5a7..53656c3854219f6901b81d163d06b8ed1b073e57 100644 (file)
@@ -5,7 +5,7 @@
 .. module:: mutex
    :synopsis: Lock and queue for mutual exclusion.
    :deprecated:
-   
+
 .. deprecated::
    The :mod:`mutex` module has been removed in Python 3.0.
 
index fdbf2a33295fb67556582e2230269d8025c658bb..6c16a439f4f6a180e980ea394c5401d790700cf6 100644 (file)
@@ -24,16 +24,16 @@ about a newsgroup and print the subjects of the last 10 articles::
    Group comp.lang.python has 59 articles, range 3742 to 3803
    >>> resp, subs = s.xhdr('subject', first + '-' + last)
    >>> for id, sub in subs[-10:]: print id, sub
-   ... 
+   ...
    3792 Re: Removing elements from a list while iterating...
    3793 Re: Who likes Info files?
    3794 Emacs and doc strings
    3795 a few questions about the Mac implementation
    3796 Re: executable python scripts
    3797 Re: executable python scripts
-   3798 Re: a few questions about the Mac implementation 
+   3798 Re: a few questions about the Mac implementation
    3799 Re: PROPOSAL: A Generic Python Object Interface for Python C Modules
-   3802 Re: executable python scripts 
+   3802 Re: executable python scripts
    3803 Re: \POSIX{} wait and SIGCHLD
    >>> s.quit()
    '205 news.cwi.nl closing connection.  Goodbye.'
index b7aafb235840e1c9f83125f41ce8ea76d82f4301..b0d55a74066c0825e2d631d97857abbc99af000e 100644 (file)
@@ -51,14 +51,14 @@ The numeric tower
    :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,
    ``%``, ``<``, ``<=``, ``>``, and ``>=``.
 
-   Real also provides defaults for :func:`complex`, :attr:`Complex.real`,
-   :attr:`Complex.imag`, and :meth:`Complex.conjugate`.
+   Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,
+   :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.
 
 
 .. class:: Rational
 
    Subtypes :class:`Real` and adds
-   :attr:`Rational.numerator` and :attr:`Rational.denominator` properties, which
+   :attr:`~Rational.numerator` and :attr:`~Rational.denominator` properties, which
    should be in lowest terms. With these, it provides a default for
    :func:`float`.
 
@@ -74,8 +74,8 @@ The numeric tower
 .. class:: Integral
 
    Subtypes :class:`Rational` and adds a conversion to :class:`int`.
-   Provides defaults for :func:`float`, :attr:`Rational.numerator`, and
-   :attr:`Rational.denominator`, and bit-string operations: ``<<``,
+   Provides defaults for :func:`float`, :attr:`~Rational.numerator`, and
+   :attr:`~Rational.denominator`, and bit-string operations: ``<<``,
    ``>>``, ``&``, ``^``, ``|``, ``~``.
 
 
@@ -171,7 +171,7 @@ Complex``. I'll consider ``a + b``:
        knowledge of ``A``, so it can handle those instances before
        delegating to :class:`Complex`.
 
-If ``A<:Complex`` and ``B<:Real`` without sharing any other knowledge,
+If ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,
 then the appropriate shared operation is the one involving the built
 in :class:`complex`, and both :meth:`__radd__` s land there, so ``a+b
 == b+a``.
index 2ab54db02d87586b0895482be519a03ec754720b..dc7ad37da57e98d6c049b58314331fb0e7649444 100644 (file)
@@ -7,7 +7,7 @@
 
 
 .. testsetup::
-   
+
    import operator
    from operator import itemgetter
 
@@ -437,7 +437,7 @@ objects.
 
       >>> class C:
       ...     pass
-      ... 
+      ...
       >>> import operator
       >>> obj = C()
       >>> operator.isMappingType(obj)
@@ -547,9 +547,9 @@ expect a function argument.
                 def g(obj):
                     return tuple(obj[item] for item in items)
             return g
-   
-   The items can be any type accepted by the operand's :meth:`__getitem__` 
-   method.  Dictionaries accept any hashable value.  Lists, tuples, and 
+
+   The items can be any type accepted by the operand's :meth:`__getitem__`
+   method.  Dictionaries accept any hashable value.  Lists, tuples, and
    strings accept an index or a slice:
 
       >>> itemgetter(1)('ABCDEFG')
index fbc2de2f05e46ad359ed326f8676149edba609d6..6af40745fbce1ed47243aa131b10e51b96724181 100644 (file)
@@ -548,8 +548,8 @@ Continuing with the parser defined above, adding an
 :class:`OptionGroup` to a parser is easy::
 
     group = OptionGroup(parser, "Dangerous Options",
-                       "Caution: use these options at your own risk.  "
-                       "It is believed that some of them bite.")
+                        "Caution: use these options at your own risk.  "
+                        "It is believed that some of them bite.")
     group.add_option("-g", action="store_true", help="Group option.")
     parser.add_option_group(group)
 
@@ -563,12 +563,12 @@ This would result in the following help output::
       -q, --quiet          be vewwy quiet (I'm hunting wabbits)
       -fFILE, --file=FILE  write output to FILE
       -mMODE, --mode=MODE  interaction mode: one of 'novice', 'intermediate'
-                          [default], 'expert'
+                           [default], 'expert'
 
       Dangerous Options:
-       Caution: use of these options is at your own risk.  It is believed that
-       some of them bite.
-       -g                 Group option.
+      Caution: use of these options is at your own risk.  It is believed that
+      some of them bite.
+      -g                 Group option.
 
 .. _optparse-printing-version-string:
 
@@ -799,7 +799,7 @@ And to define an option with only a long option string::
 The keyword arguments define attributes of the new Option object.  The most
 important option attribute is :attr:`action`, and it largely determines which
 other attributes are relevant or required.  If you pass irrelevant option
-attributes, or fail to pass required ones, :mod:`optparse` raises an 
+attributes, or fail to pass required ones, :mod:`optparse` raises an
 :exc:`OptionError` exception explaining your mistake.
 
 An option's *action* determines what :mod:`optparse` does when it encounters
index 8111fa3a019925419fa45c36296eebbbf2e3ebc6..74fca8a2eaa9fa2249ad108d1029a731b26ab4f8 100644 (file)
@@ -368,7 +368,7 @@ These functions create new file objects. (See also :func:`open`.)
    is returned. Availability: Unix, Windows.
 
    .. deprecated:: 2.6
-      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check
       especially the :ref:`subprocess-replacements` section.
 
    .. versionchanged:: 2.0
@@ -418,7 +418,7 @@ functions, see :ref:`popen2-flow-control`.
    child_stdout)``.
 
    .. deprecated:: 2.6
-      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check
       especially the :ref:`subprocess-replacements` section.
 
    Availability: Unix, Windows.
@@ -432,7 +432,7 @@ functions, see :ref:`popen2-flow-control`.
    child_stdout, child_stderr)``.
 
    .. deprecated:: 2.6
-      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check
       especially the :ref:`subprocess-replacements` section.
 
    Availability: Unix, Windows.
@@ -446,7 +446,7 @@ functions, see :ref:`popen2-flow-control`.
    child_stdout_and_stderr)``.
 
    .. deprecated:: 2.6
-      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check
       especially the :ref:`subprocess-replacements` section.
 
    Availability: Unix, Windows.
@@ -1449,7 +1449,7 @@ to be ignored.
    These functions all execute a new program, replacing the current process; they
    do not return.  On Unix, the new executable is loaded into the current process,
    and will have the same process id as the caller.  Errors will be reported as
-   :exc:`OSError` exceptions.  
+   :exc:`OSError` exceptions.
 
    The current process is replaced immediately. Open file objects and
    descriptors are not flushed, so if there may be data buffered
@@ -1481,7 +1481,7 @@ to be ignored.
    used to define the environment variables for the new process (these are used
    instead of the current process' environment); the functions :func:`execl`,
    :func:`execlp`, :func:`execv`, and :func:`execvp` all cause the new process to
-   inherit the environment of the current process. 
+   inherit the environment of the current process.
 
    Availability: Unix, Windows.
 
@@ -1718,7 +1718,7 @@ written in Python, such as a mail server's external command delivery program.
 
    (Note that the :mod:`subprocess` module provides more powerful facilities for
    spawning new processes and retrieving their results; using that module is
-   preferable to using these functions.  Check specially the *Replacing Older 
+   preferable to using these functions.  Check specially the *Replacing Older
    Functions with the subprocess Module* section in that documentation page.)
 
    If *mode* is :const:`P_NOWAIT`, this function returns the process id of the new
index e4ece4d8e6e0727fa072188f2fdb2d98672706c3..d8ff3f2ac202352fba6148e4df5af29941159230 100644 (file)
@@ -18,26 +18,26 @@ the standard audio interface for Linux and recent versions of FreeBSD.
    use ALSA, you'll have to make sure its OSS compatibility layer
    is active to use ossaudiodev, but you're gonna need it for the vast
    majority of Linux audio apps anyways.
-   
+
    Sounds like things are also complicated for other BSDs.  In response
    to my python-dev query, Thomas Wouters said:
-   
+
    > Likewise, googling shows OpenBSD also uses OSS/Free -- the commercial
    > OSS installation manual tells you to remove references to OSS/Free from the
    > kernel :)
-   
+
    but Aleksander Piotrowsk actually has an OpenBSD box, and he quotes
    from its <soundcard.h>:
    >  * WARNING!  WARNING!
    >  * This is an OSS (Linux) audio emulator.
    >  * Use the Native NetBSD API for developing new code, and this
    >  * only for compiling Linux programs.
-   
+
    There's also an ossaudio manpage on OpenBSD that explains things
    further.  Presumably NetBSD and OpenBSD have a different standard
    audio interface.  That's the great thing about standards, there are so
    many to choose from ... ;-)
-   
+
    This probably all warrants a footnote or two, but I don't understand
    things well enough right now to write it!   --GPW
 
index 2d4ea3729ad30f76ee1bd84db2e26c2c13e3c1ef..9821173ece81445a529d41a0dbfa0392d93f1765 100644 (file)
@@ -70,7 +70,7 @@ also available for Python:
       Robin Dunn.
 
 PyGTK, PyQt, and wxPython, all have a modern look and feel and more
-widgets than Tkinter. In addition, there are many other GUI toolkits for 
+widgets than Tkinter. In addition, there are many other GUI toolkits for
 Python, both cross-platform, and platform-specific. See the `GUI Programming
 <http://wiki.python.org/moin/GuiProgramming>`_ page in the Python Wiki for a
 much more complete list, and also for links to documents where the
index bdd541cd3ea825b7278420e29c183e321c66e524..b1cbd1220c245da7ffcbc0f7e7e52e31381a7788 100644 (file)
@@ -641,7 +641,7 @@ on the same line as the definition of the code block, as in ::
 while the long form uses an indented block and allows nested definitions::
 
    def make_power(exp):
-       "Make a function that raises an argument to the exponent `exp'."
+       "Make a function that raises an argument to the exponent `exp`."
        def raiser(x, y=exp):
            return x ** y
        return raiser
index 384c7d9f38bcf70e0309dd19791bc9d7862681fc..700146b6e102912a86f7a6a63ce8585366151365 100644 (file)
@@ -37,7 +37,7 @@ of the debugger is::
    (Pdb) continue
    NameError: 'spam'
    > <string>(1)?()
-   (Pdb) 
+   (Pdb)
 
 :file:`pdb.py` can also be invoked as a script to debug other scripts.  For
 example::
@@ -68,7 +68,7 @@ Typical usage to inspect a crashed program is::
    >>> pdb.pm()
    > ./mymodule.py(3)test2()
    -> print spam
-   (Pdb) 
+   (Pdb)
 
 The module defines the following functions; each enters the debugger in a
 slightly different way:
@@ -109,7 +109,7 @@ slightly different way:
 
 .. function:: post_mortem([traceback])
 
-   Enter post-mortem debugging of the given *traceback* object.  If no 
+   Enter post-mortem debugging of the given *traceback* object.  If no
    *traceback* is given, it uses the one of the exception that is currently
    being handled (an exception must be being handled if the default is to be
    used).
index cc3c036260b93e0d715563d971e5c7db43cc429b..a99dc862f4da3a5783a4e7781886e1e81e6485f0 100644 (file)
@@ -413,7 +413,7 @@ Pickling and unpickling normal class instances
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 .. method:: object.__getinitargs__()
-   
+
    When a pickled class instance is unpickled, its :meth:`__init__` method is
    normally *not* invoked.  If it is desirable that the :meth:`__init__` method
    be called on unpickling, an old-style class can define a method
@@ -430,31 +430,31 @@ Pickling and unpickling normal class instances
    is affected by the values passed to the :meth:`__new__` method for the type
    (as it is for tuples and strings).  Instances of a :term:`new-style class`
    ``C`` are created using ::
-    
+
       obj = C.__new__(C, *args)
-    
+
    where *args* is the result of calling :meth:`__getnewargs__` on the original
    object; if there is no :meth:`__getnewargs__`, an empty tuple is assumed.
 
 .. method:: object.__getstate__()
-   
+
    Classes can further influence how their instances are pickled; if the class
    defines the method :meth:`__getstate__`, it is called and the return state is
    pickled as the contents for the instance, instead of the contents of the
    instance's dictionary.  If there is no :meth:`__getstate__` method, the
    instance's :attr:`__dict__` is pickled.
 
-.. method:: object.__setstate__() 
-   
+.. method:: object.__setstate__()
+
    Upon unpickling, if the class also defines the method :meth:`__setstate__`,
    it is called with the unpickled state. [#]_ If there is no
    :meth:`__setstate__` method, the pickled state must be a dictionary and its
    items are assigned to the new instance's dictionary.  If a class defines both
    :meth:`__getstate__` and :meth:`__setstate__`, the state object needn't be a
    dictionary and these methods can do what they want. [#]_
-    
+
    .. warning::
-    
+
       For :term:`new-style class`\es, if :meth:`__getstate__` returns a false
       value, the :meth:`__setstate__` method will not be called.
 
@@ -463,7 +463,7 @@ Pickling and unpickling extension types
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 .. method:: object.__reduce__()
-   
+
    When the :class:`Pickler` encounters an object of a type it knows nothing
    about --- such as an extension type --- it looks in two places for a hint of
    how to pickle it.  One alternative is for the object to implement a
@@ -518,7 +518,7 @@ Pickling and unpickling extension types
      is primarily used for dictionary subclasses, but may be used by other
      classes as long as they implement :meth:`__setitem__`.
 
-.. method:: object.__reduce_ex__(protocol) 
+.. method:: object.__reduce_ex__(protocol)
 
    It is sometimes useful to know the protocol version when implementing
    :meth:`__reduce__`.  This can be done by implementing a method named
index a18b571547dff330ebaa68e5d224c02c4395fc05..4646dd936696fd5dc61cb48e82ea7be663c1b57b 100644 (file)
@@ -9,7 +9,7 @@
 
 
 .. deprecated:: 2.6
-   This module is obsolete.  Use the :mod:`subprocess` module.  Check 
+   This module is obsolete.  Use the :mod:`subprocess` module.  Check
    especially the :ref:`subprocess-replacements` section.
 
 This module allows you to spawn processes and connect to their
index 4c0ba1552b89c3e72ca99666fa9fbafe60bca6af..4d71437cfe606063b496378f5b5415af82341b21 100644 (file)
@@ -51,17 +51,17 @@ examine the results of a profile operation.
 
 The Python standard library provides three different profilers:
 
-#. :mod:`cProfile` is recommended for most users; it's a C extension 
+#. :mod:`cProfile` is recommended for most users; it's a C extension
    with reasonable overhead
-   that makes it suitable for profiling long-running programs. 
+   that makes it suitable for profiling long-running programs.
    Based on :mod:`lsprof`,
-   contributed by Brett Rosen and Ted Czotter.  
+   contributed by Brett Rosen and Ted Czotter.
 
    .. versionadded:: 2.5
 
 #. :mod:`profile`, a pure Python module whose interface is imitated by
-   :mod:`cProfile`.  Adds significant overhead to profiled programs. 
-   If you're trying to extend 
+   :mod:`cProfile`.  Adds significant overhead to profiled programs.
+   If you're trying to extend
    the profiler in some way, the task might be easier with this module.
    Copyright Â© 1994, by InfoSeek Corporation.
 
@@ -72,7 +72,7 @@ The Python standard library provides three different profilers:
    the overhead of profiling, at the expense of longer data
    post-processing times.  It is no longer maintained and may be
    dropped in a future version of Python.
+
 
    .. versionchanged:: 2.5
       The results should be more meaningful than in the past: the timing core
@@ -276,24 +276,24 @@ reading the source code for these modules.
    that the text string in the far right column was used to sort the output. The
    column headings include:
 
-   ncalls 
+   ncalls
       for the number of calls,
 
-   tottime 
+   tottime
       for the total time spent in the given function (and excluding time made in calls
       to sub-functions),
 
-   percall 
+   percall
       is the quotient of ``tottime`` divided by ``ncalls``
 
-   cumtime 
+   cumtime
       is the total time spent in this and all subfunctions (from invocation till
       exit). This figure is accurate *even* for recursive functions.
 
-   percall 
+   percall
       is the quotient of ``cumtime`` divided by primitive calls
 
-   filename:lineno(function) 
+   filename:lineno(function)
       provides the respective data of each function
 
    When there are two numbers in the first column (for example, ``43/3``), then the
index 1d5e6e6983e876699841f904e204cc9a20d716a9..04179a4a4567a29dab7065d39ff01c7606d7be29 100644 (file)
@@ -182,9 +182,9 @@ XMLParser Objects
 
 .. attribute:: xmlparser.buffer_size
 
-   The size of the buffer used when :attr:`buffer_text` is true.  
-   A new buffer size can be set by assigning a new integer value 
-   to this attribute.  
+   The size of the buffer used when :attr:`buffer_text` is true.
+   A new buffer size can be set by assigning a new integer value
+   to this attribute.
    When the size is changed, the buffer will be flushed.
 
    .. versionadded:: 2.3
index 916fecaef579ecc95ce106600d140f9ec05f472c..96b452ecc6e70c1b2bf8e84f5e3ddbb8a70c3862 100644 (file)
@@ -994,14 +994,14 @@ method of :class:`MatchObject` in the following manner:
 
    >>> pair.match("717ak").group(1)
    '7'
-   
+
    # Error because re.match() returns None, which doesn't have a group() method:
    >>> pair.match("718ak").group(1)
    Traceback (most recent call last):
      File "<pyshell#23>", line 1, in <module>
        re.match(r".*(.).*\1", "718ak").group(1)
    AttributeError: 'NoneType' object has no attribute 'group'
-   
+
    >>> pair.match("354aa").group(1)
    'a'
 
@@ -1110,7 +1110,7 @@ where the search is to start:
 Making a Phonebook
 ^^^^^^^^^^^^^^^^^^
 
-:func:`split` splits a string into a list delimited by the passed pattern.  The 
+:func:`split` splits a string into a list delimited by the passed pattern.  The
 method is invaluable for converting textual data into data structures that can be
 easily read and modified by Python as demonstrated in the following example that
 creates a phonebook.
@@ -1119,7 +1119,7 @@ First, here is the input.  Normally it may come from a file, here we are using
 triple-quoted string syntax:
 
    >>> input = """Ross McFluff: 834.345.1254 155 Elm Street
-   ... 
+   ...
    ... Ronald Heathmore: 892.345.3428 436 Finley Avenue
    ... Frank Burger: 925.541.7625 662 South Dogwood Way
    ...
index 29c5a61b4f10c8002f5629b174586a3941d49f34..2b75257440cc1f332aa15b34d6ee6f6f185ce344 100644 (file)
@@ -125,15 +125,15 @@ The use of dynamic dispatching by :meth:`Repr.repr1` allows subclasses of
 the handling of types already supported. This example shows how special support
 for file objects could be added::
 
-   import repr
+   import repr as reprlib
    import sys
 
-   class MyRepr(repr.Repr):
+   class MyRepr(reprlib.Repr):
        def repr_file(self, obj, level):
            if obj.name in ['<stdin>', '<stdout>', '<stderr>']:
                return obj.name
            else:
-               return `obj`
+               return repr(obj)
 
    aRepr = MyRepr()
    print aRepr.repr(sys.stdin)          # prints '<stdin>'
index 3bc3fc94edd08499864b0724d34b654ad195d52b..e25e5c9f20a9699cc694345436d198fb6beb84c5 100644 (file)
@@ -5,7 +5,7 @@
 .. module:: rexec
    :synopsis: Basic restricted execution framework.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`rexec` module has been removed in Python 3.0.
 
@@ -272,7 +272,7 @@ Let us say that we want a slightly more relaxed policy than the standard
                pass
            elif mode in ('w', 'wb', 'a', 'ab'):
                # check filename : must begin with /tmp/
-               if file[:5]!='/tmp/': 
+               if file[:5]!='/tmp/':
                    raise IOError, "can't write outside /tmp"
                elif (string.find(file, '/../') >= 0 or
                     file[:3] == '../' or file[-3:] == '/..'):
index 060f2969e61fea484129e92029e38cfed2e6f4de..50f1afd3484989471e4484f0bcc943ba21541331 100644 (file)
@@ -61,6 +61,6 @@ Completer objects have the following method:
    If called for a dotted name, it will try to evaluate anything without obvious
    side-effects (functions will not be evaluated, but it can generate calls to
    :meth:`__getattr__`) up to the last part, and find matches for the rest via the
-   :func:`dir` function.  Any exception raised during the evaluation of the 
+   :func:`dir` function.  Any exception raised during the evaluation of the
    expression is caught, silenced and :const:`None` is returned.
 
index fb261231c50320107995f922fb366a01a227c926..ba7e557873beeb6d7d11397410f2878cbb212f08 100644 (file)
@@ -13,7 +13,7 @@
    single: World Wide Web
    single: URL
    single: robots.txt
-   
+
 .. note::
    The :mod:`robotparser` module has been renamed :mod:`urllib.robotparser` in
    Python 3.0.
index 3b83f4ac4f19e5ed625ab645710b91038c6f5eb1..2283077bd0dc89e1f014e4396604310fc10a5fa0 100644 (file)
@@ -42,7 +42,7 @@ Example::
    930343700.276
 
 In multi-threaded environments, the :class:`scheduler` class has limitations
-with respect to thread-safety, inability to insert a new task before 
+with respect to thread-safety, inability to insert a new task before
 the one currently pending in a running scheduler, and holding up the main
 thread until the event queue is empty.  Instead, the preferred approach
 is to use the :class:`threading.Timer` class instead.
@@ -58,8 +58,8 @@ Example::
     ...     print time.time()
     ...     Timer(5, print_time, ()).start()
     ...     Timer(10, print_time, ()).start()
-    ...     time.sleep(11)     # sleep while time-delay events execute
-    ...     print time.time()     
+    ...     time.sleep(11)  # sleep while time-delay events execute
+    ...     print time.time()
     ...
     >>> print_some_times()
     930343690.257
index 93c0cde66a66af6825540e5e67044185657420da..f50b02c178ff09937ca6553742910d1b0e940d28 100644 (file)
@@ -4,7 +4,7 @@
 .. module:: sgmllib
    :synopsis: Only as much of an SGML parser as needed to parse HTML.
    :deprecated:
-   
+
 .. deprecated:: 2.6
     The :mod:`sgmllib` module has been removed in Python 3.0.
 
index 7baff30a4cc06ca221ab29c128f46e195db584c6..e09b646e161f188e8b61e0bab61fb7311bc71fea 100644 (file)
@@ -20,7 +20,7 @@ copying and removal. For operations on individual files, see also the
 
    Even the higher-level file copying functions (:func:`copy`, :func:`copy2`)
    can't copy all file metadata.
-   
+
    On POSIX platforms, this means that file owner and group are lost as well
    as ACLs.  On Mac OS, the resource fork and other metadata are not used.
    This means that resources will be lost and file type and creator codes will
@@ -124,7 +124,7 @@ copying and removal. For operations on individual files, see also the
       error. Copy permissions and times of directories using :func:`copystat`.
 
    .. versionchanged:: 2.6
-      Added the *ignore* argument to be able to influence what is being copied. 
+      Added the *ignore* argument to be able to influence what is being copied.
 
 
 .. function:: rmtree(path[, ignore_errors[, onerror]])
@@ -189,7 +189,7 @@ provided by this module. ::
        os.makedirs(dst)
        errors = []
        for name in names:
-           if name in ignored_names:   
+           if name in ignored_names:
                continue
            srcname = os.path.join(src, name)
            dstname = os.path.join(dst, name)
@@ -221,7 +221,7 @@ provided by this module. ::
 Another example that uses the :func:`ignore_patterns` helper::
 
    from shutil import copytree, ignore_patterns
-   
+
    copytree(source, destination, ignore=ignore_patterns('*.pyc', 'tmp*'))
 
 This will copy everything except ``.pyc`` files and files or directories whose
@@ -231,7 +231,7 @@ Another example that uses the *ignore* argument to add a logging call::
 
    from shutil import copytree
    import logging
-   
+
    def _logpath(path, names):
        logging.info('Working in %s' % path)
        return []   # nothing will be ignored
index 561a1c7f75fba47c71b901ed807ca0168d0c635c..3793a89b03a909bb0cbf143db057bc40ba553d1c 100644 (file)
@@ -39,12 +39,12 @@ rules for working with signals and their handlers:
 * Some care must be taken if both signals and threads are used in the same
   program.  The fundamental thing to remember in using signals and threads
   simultaneously is: always perform :func:`signal` operations in the main thread
-  of execution.  Any thread can perform an :func:`alarm`, :func:`getsignal`, 
-  :func:`pause`, :func:`setitimer` or :func:`getitimer`; only the main thread 
-  can set a new signal handler, and the main thread will be the only one to 
-  receive signals (this is enforced by the Python :mod:`signal` module, even 
-  if the underlying thread implementation supports sending signals to 
-  individual threads).  This means that signals can't be used as a means of 
+  of execution.  Any thread can perform an :func:`alarm`, :func:`getsignal`,
+  :func:`pause`, :func:`setitimer` or :func:`getitimer`; only the main thread
+  can set a new signal handler, and the main thread will be the only one to
+  receive signals (this is enforced by the Python :mod:`signal` module, even
+  if the underlying thread implementation supports sending signals to
+  individual threads).  This means that signals can't be used as a means of
   inter-thread communication.  Use locks instead.
 
 The variables defined in the :mod:`signal` module are:
@@ -80,22 +80,22 @@ The variables defined in the :mod:`signal` module are:
    One more than the number of the highest signal number.
 
 
-.. data:: ITIMER_REAL    
+.. data:: ITIMER_REAL
 
    Decrements interval timer in real time, and delivers :const:`SIGALRM` upon expiration.
 
 
-.. data:: ITIMER_VIRTUAL 
+.. data:: ITIMER_VIRTUAL
 
-   Decrements interval timer only when the process is executing, and delivers 
+   Decrements interval timer only when the process is executing, and delivers
    SIGVTALRM upon expiration.
 
 
 .. data:: ITIMER_PROF
-   
-   Decrements interval timer both when the process executes and when the 
-   system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, 
-   this timer is usually used to profile the time spent by the application 
+
+   Decrements interval timer both when the process executes and when the
+   system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL,
+   this timer is usually used to profile the time spent by the application
    in user and kernel space. SIGPROF is delivered upon expiration.
 
 
@@ -105,7 +105,7 @@ The :mod:`signal` module defines one exception:
 
    Raised to signal an error from the underlying :func:`setitimer` or
    :func:`getitimer` implementation. Expect this error if an invalid
-   interval timer or a negative time is passed to :func:`setitimer`. 
+   interval timer or a negative time is passed to :func:`setitimer`.
    This error is a subtype of :exc:`IOError`.
 
 
@@ -143,21 +143,21 @@ The :mod:`signal` module defines the following functions:
 
 .. function:: setitimer(which, seconds[, interval])
 
-   Sets given interval timer (one of :const:`signal.ITIMER_REAL`, 
+   Sets given interval timer (one of :const:`signal.ITIMER_REAL`,
    :const:`signal.ITIMER_VIRTUAL` or :const:`signal.ITIMER_PROF`) specified
-   by *which* to fire after *seconds* (float is accepted, different from 
+   by *which* to fire after *seconds* (float is accepted, different from
    :func:`alarm`) and after that every *interval* seconds. The interval
    timer specified by *which* can be cleared by setting seconds to zero.
 
    When an interval timer fires, a signal is sent to the process.
-   The signal sent is dependent on the timer being used; 
-   :const:`signal.ITIMER_REAL` will deliver :const:`SIGALRM`, 
+   The signal sent is dependent on the timer being used;
+   :const:`signal.ITIMER_REAL` will deliver :const:`SIGALRM`,
    :const:`signal.ITIMER_VIRTUAL` sends :const:`SIGVTALRM`,
    and :const:`signal.ITIMER_PROF` will deliver :const:`SIGPROF`.
 
    The old values are returned as a tuple: (delay, interval).
 
-   Attempting to pass an invalid interval timer will cause a 
+   Attempting to pass an invalid interval timer will cause a
    :exc:`ItimerError`.
 
    .. versionadded:: 2.6
@@ -190,7 +190,7 @@ The :mod:`signal` module defines the following functions:
    will be restarted when interrupted by signal *signalnum*, otherwise system calls will
    be interrupted. Returns nothing. Availability: Unix (see the man page
    :manpage:`siginterrupt(3)` for further information).
-   
+
    Note that installing a signal handler with :func:`signal` will reset the restart
    behaviour to interruptible by implicitly calling :cfunc:`siginterrupt` with a true *flag*
    value for the given signal.
@@ -239,7 +239,7 @@ be sent, and the handler raises an exception. ::
    signal.alarm(5)
 
    # This open() may hang indefinitely
-   fd = os.open('/dev/ttyS0', os.O_RDWR)  
+   fd = os.open('/dev/ttyS0', os.O_RDWR)
 
    signal.alarm(0)          # Disable the alarm
 
index e77ac779ad2b7f97f8393ab990b2946573beff79..1591f90b6e64a57efe7df2b1126d621da99bd1f9 100644 (file)
@@ -151,7 +151,7 @@ Server code::
                                requestHandler=RequestHandler)
    server.register_introspection_functions()
 
-   # Register pow() function; this will use the value of 
+   # Register pow() function; this will use the value of
    # pow.__name__ as the name, which is just 'pow'.
    server.register_function(pow)
 
@@ -160,10 +160,10 @@ Server code::
        return x + y
    server.register_function(adder_function, 'add')
 
-   # Register an instance; all the methods of the instance are 
+   # Register an instance; all the methods of the instance are
    # published as XML-RPC methods (in this case, just 'div').
    class MyFuncs:
-       def div(self, x, y): 
+       def div(self, x, y):
            return x // y
 
    server.register_instance(MyFuncs())
index bdbbe4a0288658b2e8887b3b92259e08dcad568e..8facc9a6d81137a95258f1af361fe2b58e643758 100644 (file)
@@ -189,9 +189,9 @@ An :class:`SMTP` instance has the following methods:
 
    Identify yourself to an ESMTP server using ``EHLO``.  The hostname argument
    defaults to the fully qualified domain name of the local host.  Examine the
-   response for ESMTP option and store them for use by :meth:`has_extn`. 
-   Also sets several informational attributes: the message returned by 
-   the server is stored as the :attr:`ehlo_resp` attribute, :attr:`does_esmtp` 
+   response for ESMTP option and store them for use by :meth:`has_extn`.
+   Also sets several informational attributes: the message returned by
+   the server is stored as the :attr:`ehlo_resp` attribute, :attr:`does_esmtp`
    is set to true or false depending on whether the server supports ESMTP, and
    :attr:`esmtp_features` will be a dictionary containing the names of the
    SMTP service extensions this server supports, and their
@@ -207,7 +207,7 @@ An :class:`SMTP` instance has the following methods:
    previous ``EHLO`` or ``HELO`` command this session.  It tries ESMTP ``EHLO``
    first.
 
-   :exc:SMTPHeloError
+   :exc:`SMTPHeloError`
      The server didn't reply properly to the ``HELO`` greeting.
 
    .. versionadded:: 2.6
index a7e746e136be100450637c7b6f6f2e9d435873c6..4f2a32ecf0402ec4641d744bfe5d426447eba76f 100644 (file)
@@ -184,10 +184,10 @@ The module :mod:`socket` exports the following constants and functions:
 
 .. data:: SIO_*
           RCVALL_*
-          
+
    Constants for Windows' WSAIoctl(). The constants are used as arguments to the
    :meth:`ioctl` method of socket objects.
-   
+
    .. versionadded:: 2.6
 
 .. data:: TIPC_*
@@ -222,7 +222,7 @@ The module :mod:`socket` exports the following constants and functions:
    all the necessary arguments for creating the corresponding socket. *host* is a domain
    name, a string representation of an IPv4/v6 address or ``None``. *port* is a string
    service name such as ``'http'``, a numeric port number or ``None``.
-   The rest of the arguments are optional and must be numeric if specified.  
+   The rest of the arguments are optional and must be numeric if specified.
    By passing ``None`` as the value of *host* and *port*, , you can pass ``NULL`` to the C API.
 
    The :func:`getaddrinfo` function returns a list of 5-tuples with the following
@@ -588,14 +588,14 @@ correspond to Unix system calls applicable to sockets.
    contents of the buffer (see the optional built-in module :mod:`struct` for a way
    to decode C structures encoded as strings).
 
-   
+
 .. method:: socket.ioctl(control, option)
 
-   :platform: Windows 
-   
+   :platform: Windows
+
    The :meth:`ioctl` method is a limited interface to the WSAIoctl system
    interface. Please refer to the MSDN documentation for more information.
-   
+
    .. versionadded:: 2.6
 
 
@@ -852,20 +852,21 @@ sends traffic to the first one connected successfully. ::
    HOST = None               # Symbolic name meaning all available interfaces
    PORT = 50007              # Arbitrary non-privileged port
    s = None
-   for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+   for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC,
+                                 socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
        af, socktype, proto, canonname, sa = res
        try:
-       s = socket.socket(af, socktype, proto)
+           s = socket.socket(af, socktype, proto)
        except socket.error, msg:
-       s = None
-       continue
+           s = None
+           continue
        try:
-       s.bind(sa)
-       s.listen(1)
+           s.bind(sa)
+           s.listen(1)
        except socket.error, msg:
-       s.close()
-       s = None
-       continue
+           s.close()
+           s = None
+           continue
        break
    if s is None:
        print 'could not open socket'
@@ -890,16 +891,16 @@ sends traffic to the first one connected successfully. ::
    for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM):
        af, socktype, proto, canonname, sa = res
        try:
-       s = socket.socket(af, socktype, proto)
+           s = socket.socket(af, socktype, proto)
        except socket.error, msg:
-       s = None
-       continue
+           s = None
+           continue
        try:
-       s.connect(sa)
+           s.connect(sa)
        except socket.error, msg:
-       s.close()
-       s = None
-       continue
+           s.close()
+           s = None
+           continue
        break
    if s is None:
        print 'could not open socket'
@@ -909,7 +910,7 @@ sends traffic to the first one connected successfully. ::
    s.close()
    print 'Received', repr(data)
 
-   
+
 The last example shows how to write a very simple network sniffer with raw
 sockets on Windows. The example requires administrator privileges to modify
 the interface::
@@ -918,19 +919,19 @@ the interface::
 
    # the public network interface
    HOST = socket.gethostbyname(socket.gethostname())
-   
+
    # create a raw socket and bind it to the public interface
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
    s.bind((HOST, 0))
-   
+
    # Include IP headers
    s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
-   
+
    # receive all packages
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
-   
+
    # receive a package
    print s.recvfrom(65565)
-   
+
    # disabled promiscuous mode
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
index 786632edc24ca6fb4dd0f9253dc5516959253457..6ae9038daa8b31ac643cb31e52347ae240358b35 100644 (file)
@@ -7,9 +7,9 @@
 
 .. note::
 
-   The :mod:`SocketServer` module has been renamed to `socketserver` in Python
-   3.0.  The :term:`2to3` tool will automatically adapt imports when converting
-   your sources to 3.0.
+   The :mod:`SocketServer` module has been renamed to :mod:`socketserver` in
+   Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
+   converting your sources to 3.0.
 
 
 The :mod:`SocketServer` module simplifies the task of writing network servers.
index 19b80abbe584fd6afc31cd747bb1cbe11316b1cf..d031c909755cf9ee09b66fcf06f280d767e145ef 100644 (file)
@@ -244,7 +244,7 @@ Connection Objects
 
 .. method:: Connection.rollback()
 
-   This method rolls back any changes to the database since the last call to 
+   This method rolls back any changes to the database since the last call to
    :meth:`commit`.
 
 .. method:: Connection.close()
@@ -487,29 +487,29 @@ Cursor Objects
    .. literalinclude:: ../includes/sqlite3/executescript.py
 
 
-.. method:: Cursor.fetchone() 
-          
+.. method:: Cursor.fetchone()
+
    Fetches the next row of a query result set, returning a single sequence,
    or :const:`None` when no more data is available.
 
 
 .. method:: Cursor.fetchmany([size=cursor.arraysize])
-          
+
    Fetches the next set of rows of a query result, returning a list.  An empty
    list is returned when no more rows are available.
-   
+
    The number of rows to fetch per call is specified by the *size* parameter.
    If it is not given, the cursor's arraysize determines the number of rows
    to be fetched. The method should try to fetch as many rows as indicated by
    the size parameter. If this is not possible due to the specified number of
    rows not being available, fewer rows may be returned.
-   
+
    Note there are performance considerations involved with the *size* parameter.
    For optimal performance, it is usually best to use the arraysize attribute.
    If the *size* parameter is used, then it is best for it to retain the same
    value from one :meth:`fetchmany` call to the next.
-            
-.. method:: Cursor.fetchall() 
+
+.. method:: Cursor.fetchall()
 
    Fetches all (remaining) rows of a query result, returning a list.  Note that
    the cursor's arraysize attribute can affect the performance of this operation.
@@ -546,8 +546,8 @@ Cursor Objects
 
    This read-only attribute provides the column names of the last query. To
    remain compatible with the Python DB API, it returns a 7-tuple for each
-   column where the last six items of each tuple are :const:`None`. 
-   
+   column where the last six items of each tuple are :const:`None`.
+
    It is set for ``SELECT`` statements without any matching rows as well.
 
 .. _sqlite3-row-objects:
@@ -558,7 +558,7 @@ Row Objects
 .. class:: Row
 
    A :class:`Row` instance serves as a highly optimized
-   :attr:`~Connection.row_factory` for :class:`Connection` objects. 
+   :attr:`~Connection.row_factory` for :class:`Connection` objects.
    It tries to mimic a tuple in most of its features.
 
    It supports mapping access by column name and index, iteration,
@@ -566,7 +566,7 @@ Row Objects
 
    If two :class:`Row` objects have exactly the same columns and their
    members are equal, they compare equal.
-   
+
    .. versionchanged:: 2.6
       Added iteration and equality (hashability).
 
@@ -793,7 +793,7 @@ Controlling Transactions
 ------------------------
 
 By default, the :mod:`sqlite3` module opens transactions implicitly before a
-Data Modification Language (DML)  statement (i.e. 
+Data Modification Language (DML)  statement (i.e.
 ``INSERT``/``UPDATE``/``DELETE``/``REPLACE``), and commits transactions
 implicitly before a non-DML, non-query statement (i. e.
 anything other than ``SELECT`` or the aforementioned).
index 4fcc2f40df6fd5452fce9b0d5f66cf939fed530e..30f1fea9d1b85da82ea6abc2cff386fe424d7543 100644 (file)
@@ -48,7 +48,7 @@ Functions, Constants, and Exceptions
 
 .. exception:: SSLError
 
-   Raised to signal an error from the underlying SSL implementation.  This 
+   Raised to signal an error from the underlying SSL implementation.  This
    signifies some problem in the higher-level
    encryption and authentication layer that's superimposed on the underlying
    network connection.  This error is a subtype of :exc:`socket.error`, which
@@ -173,7 +173,7 @@ Functions, Constants, and Exceptions
      >>> import time
      >>> time.ctime(ssl.cert_time_to_seconds("May  9 00:00:00 2007 GMT"))
      'Wed May  9 00:00:00 2007'
-     >>> 
+     >>>
 
 .. function:: get_server_certificate (addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None)
 
@@ -385,7 +385,7 @@ should start with the specific certificate for the principal who "is"
 the client or server, and then the certificate for the issuer of that
 certificate, and then the certificate for the issuer of *that* certificate,
 and so on up the chain till you get to a certificate which is *self-signed*,
-that is, a certificate which has the same subject and issuer, 
+that is, a certificate which has the same subject and issuer,
 sometimes called a *root certificate*.  The certificates should just
 be concatenated together in the certificate file.  For example, suppose
 we had a three certificate chain, from our server certificate to the
@@ -422,13 +422,13 @@ SSL3 or TLS1, you don't need to put the full chain in your "CA certs" file;
 you only need the root certificates, and the remote peer is supposed to
 furnish the other certificates necessary to chain from its certificate to
 a root certificate.
-See :rfc:`4158` for more discussion of the way in which 
+See :rfc:`4158` for more discussion of the way in which
 certification chains can be built.
 
 If you are going to create a server that provides SSL-encrypted
 connection services, you will need to acquire a certificate for that
 service.  There are many ways of acquiring appropriate certificates,
-such as buying one from a certification authority.  Another common 
+such as buying one from a certification authority.  Another common
 practice is to generate a self-signed certificate.  The simplest
 way to do this is with the OpenSSL package, using something like
 the following::
@@ -570,7 +570,7 @@ Then you'd read data from the ``connstream`` and do something with it till you a
 
 And go back to listening for new client connections.
 
-           
+
 .. seealso::
 
    Class :class:`socket.socket`
index 63fcfa4b58b11e75c3d69b7c9151a86d3d5b8616..25355bcbafead53351792e3447d2870b2e98469b 100644 (file)
@@ -4,7 +4,7 @@
 .. module:: statvfs
    :synopsis: Constants for interpreting the result of os.statvfs().
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`statvfs` module has been deprecated for removal in Python 3.0.
 
index f63e9dc0ce88f05e3a8a55d961a31cae75fc2daa..dc22776851631e00215ac33fb8edeb05af5a13c9 100644 (file)
@@ -360,9 +360,9 @@ Notes:
    though the result's type is not necessarily int.
 
 (6)
-   float also accepts the strings "nan" and "inf" with an optional prefix "+" 
+   float also accepts the strings "nan" and "inf" with an optional prefix "+"
    or "-" for Not a Number (NaN) and positive or negative infinity.
-   
+
    .. versionadded:: 2.6
 
 (7)
@@ -456,7 +456,7 @@ The float type has some additional methods.
     original float and with a positive denominator.  Raises
     :exc:`OverflowError` on infinities and a :exc:`ValueError` on
     NaNs.
-    
+
     .. versionadded:: 2.6
 
 Two methods support conversion to
@@ -1176,7 +1176,7 @@ string functions based on regular expressions.
    Return the numeric string left filled with zeros in a string of length
    *width*.  A sign prefix is handled correctly.  The original string is
    returned if *width* is less than ``len(s)``.
-   
+
 
    .. versionadded:: 2.2.2
 
@@ -1188,7 +1188,7 @@ The following methods are present only on unicode objects:
    otherwise. Numeric characters include digit characters, and all characters
    that have the Unicode numeric value property, e.g. U+2155,
    VULGAR FRACTION ONE FIFTH.
-   
+
 .. method:: unicode.isdecimal()
 
    Return ``True`` if there are only decimal characters in S, ``False``
@@ -1865,7 +1865,7 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
       Return the item of *d* with key *key*.  Raises a :exc:`KeyError` if *key*
       is not in the map.
 
-      .. versionadded:: 2.5 
+      .. versionadded:: 2.5
          If a subclass of dict defines a method :meth:`__missing__`, if the key
          *key* is not present, the ``d[key]`` operation calls that method with
          the key *key* as argument.  The ``d[key]`` operation then returns or
@@ -2184,7 +2184,7 @@ Files have the following methods:
    positioning); other values are ``os.SEEK_CUR`` or ``1`` (seek relative to the
    current position) and ``os.SEEK_END`` or ``2``  (seek relative to the file's
    end).  There is no return value.
-   
+
    For example, ``f.seek(2, os.SEEK_CUR)`` advances the position by two and
    ``f.seek(-3, os.SEEK_END)`` sets the position to the third to last.
 
index c9608030099a54e5f7992a3fd5fa73daa9e4e8cb..673f756bc6dc22f70727153aefca2d09500e08f3 100644 (file)
@@ -126,7 +126,7 @@ string formatting behaviors using the same implementation as the built-in
       :meth:`format` is just a wrapper that calls :meth:`vformat`.
 
    .. method:: vformat(format_string, args, kwargs)
-   
+
       This function does the actual work of formatting.  It is exposed as a
       separate function for cases where you want to pass in a predefined
       dictionary of arguments, rather than unpacking and repacking the
@@ -139,12 +139,12 @@ string formatting behaviors using the same implementation as the built-in
    intended to be replaced by subclasses:
 
    .. method:: parse(format_string)
-   
+
       Loop over the format_string and return an iterable of tuples
       (*literal_text*, *field_name*, *format_spec*, *conversion*).  This is used
       by :meth:`vformat` to break the string in to either literal text, or
       replacement fields.
-      
+
       The values in the tuple conceptually represent a span of literal text
       followed by a single replacement field.  If there is no literal text
       (which can happen if two replacement fields occur consecutively), then
@@ -162,7 +162,7 @@ string formatting behaviors using the same implementation as the built-in
       *key* parameter to :meth:`get_value`.
 
    .. method:: get_value(key, args, kwargs)
-   
+
       Retrieve a given field value.  The *key* argument will be either an
       integer or a string.  If it is an integer, it represents the index of the
       positional argument in *args*; if it is a string, then it represents a
@@ -200,7 +200,7 @@ string formatting behaviors using the same implementation as the built-in
       method is provided so that subclasses can override it.
 
    .. method:: convert_field(value, conversion)
-   
+
       Converts the value (returned by :meth:`get_field`) given a conversion type
       (as in the tuple returned by the :meth:`parse` method.)  The default
       version understands 'r' (repr) and 's' (str) conversion types.
@@ -229,7 +229,7 @@ The grammar for a replacement field is as follows:
       element_index: `integer`
       conversion: "r" | "s"
       format_spec: <described in the next section>
-      
+
 In less formal terms, the replacement field starts with a *field_name*, which
 can either be a number (for a positional argument), or an identifier (for
 keyword arguments).  Following this is an optional *conversion* field, which is
@@ -249,7 +249,7 @@ Some simple format string examples::
    "My quest is {name}"             # References keyword argument 'name'
    "Weight in tons {0.weight}"      # 'weight' attribute of first positional arg
    "Units destroyed: {players[0]}"  # First element of keyword argument 'players'.
-   
+
 The *conversion* field causes a type coercion before formatting.  Normally, the
 job of formatting a value is done by the :meth:`__format__` method of the value
 itself.  However, in some cases it is desirable to force a type to be formatted
@@ -292,11 +292,11 @@ effectively::
 Then the outer replacement field would be evaluated, producing::
 
    "noses     "
-   
+
 Which is substituted into the string, yielding::
-   
+
    "A man with two noses     "
-   
+
 (The extra space is because we specified a field width of 10, and because left
 alignment is the default for strings.)
 
@@ -328,7 +328,7 @@ The general form of a *standard format specifier* is:
    width: `integer`
    precision: `integer`
    type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "x" | "X" | "%"
-   
+
 The *fill* character can be any character other than '}' (which signifies the
 end of the field).  The presence of a fill character is signaled by the *next*
 character, which must be one of the alignment options. If the second character
@@ -421,9 +421,9 @@ The available integer presentation types are:
    +---------+----------------------------------------------------------+
    | None    | The same as ``'d'``.                                     |
    +---------+----------------------------------------------------------+
-                                                                         
+
 The available presentation types for floating point and decimal values are:
-                                                                         
+
    +---------+----------------------------------------------------------+
    | Type    | Meaning                                                  |
    +=========+==========================================================+
index 19e15473fdf17edb848b49745fb3a08c1b05bbc7..f7f6771c2a73e6d2a5507dbfe9a00f0cc4840502 100644 (file)
@@ -52,7 +52,7 @@ Example usage::
    # 'First line.\nSecond line.\n'
    contents = output.getvalue()
 
-   # Close object and discard memory buffer -- 
+   # Close object and discard memory buffer --
    # .getvalue() will now raise an exception.
    output.close()
 
@@ -81,7 +81,7 @@ encoded as plain ASCII strings.
 
 Calling :func:`StringIO` with a Unicode string parameter populates
 the object with the buffer representation of the Unicode string, instead of
-encoding the string. 
+encoding the string.
 
 Another difference from the :mod:`StringIO` module is that calling
 :func:`StringIO` with a string parameter creates a read-only object. Unlike an
@@ -118,7 +118,7 @@ Example usage::
    # 'First line.\nSecond line.\n'
    contents = output.getvalue()
 
-   # Close object and discard memory buffer -- 
+   # Close object and discard memory buffer --
    # .getvalue() will now raise an exception.
    output.close()
 
index cea8b72e5e05c7da1116a59f33b1664cc8178512..250a9267b9bd16289fac80ef73b2057ce495f171 100644 (file)
@@ -131,7 +131,7 @@ This module defines one class called :class:`Popen`:
    Special value that can be used as the *stderr* argument to :class:`Popen` and
    indicates that standard error should go into the same handle as standard
    output.
-   
+
 
 Convenience Functions
 ^^^^^^^^^^^^^^^^^^^^^
@@ -302,7 +302,7 @@ The following attributes are also available:
    The child return code, set by :meth:`poll` and :meth:`wait` (and indirectly
    by :meth:`communicate`).  A ``None`` value indicates that the process
    hasn't terminated yet.
-   
+
    A negative value ``-N`` indicates that the child was terminated by signal
    ``N`` (Unix only).
 
index a34929e063a7f5f90f28bd090af552148c33e8e5..4d67b21eb9a389919c2b8a9349425d930f76467a 100644 (file)
@@ -6,7 +6,7 @@
    :platform: SunOS
    :synopsis: Access to Sun audio hardware.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`sunaudiodev` module has been deprecated for removal in Python 3.0.
 
@@ -151,7 +151,7 @@ the SIGPOLL signal.  Here's an example of how you might enable this in Python::
    :platform: SunOS
    :synopsis: Constants for use with sunaudiodev.
    :deprecated:
-   
+
 .. deprecated:: 2.6
    The :mod:`SUNAUDIODEV` module has been deprecated for removal in Python 3.0.
 
index fa7b7f098b7ea93e4a73decbeb090b34c8306519..1000694c7d02444c730ef72bcdf1d972b1e39b09 100644 (file)
@@ -402,7 +402,7 @@ always available.
 
    The *default* argument allows to define a value which will be returned
    if the object type does not provide means to retrieve the size and would
-   cause a `TypeError`. 
+   cause a `TypeError`.
 
    func:`getsizeof` calls the object's __sizeof__ method and adds an additional
    garbage collector overhead if the object is managed by the garbage collector.
@@ -731,7 +731,7 @@ always available.
 
    The events have the following meaning:
 
-   ``'call'`` 
+   ``'call'``
       A function is called (or some other code block entered).  The
       global trace function is called; *arg* is ``None``; the return value
       specifies the local trace function.
@@ -799,7 +799,7 @@ always available.
    prompts of :func:`input` and :func:`raw_input`. The interpreter's own prompts
    and (almost all of) its error messages go to ``stderr``.  ``stdout`` and
    ``stderr`` needn't be built-in file objects: any object is acceptable as long
-   as it has a :meth:`write` method that takes a string argument.  (Changing these 
+   as it has a :meth:`write` method that takes a string argument.  (Changing these
    objects doesn't affect the standard I/O streams of processes executed by
    :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in
    the :mod:`os` module.)
index 9db66a3f7c5f8ff76e21522339a8702a8365f0ed..e4838efa84293211fe02ef244f083f702a1d6b3f 100644 (file)
@@ -164,11 +164,11 @@ The module defines the following user-callable functions:
 
    .. warning::
 
-      Use of this function may introduce a security hole in your program.
-      By the time you get around to doing anything with the file name it
-      returns, someone else may have beaten you to the punch.
-      :func:`mktemp` usage can be replaced easily with
-      :func:`NamedTemporaryFile`, passing it the  `delete=False` parameter::
+      Use of this function may introduce a security hole in your program.  By
+      the time you get around to doing anything with the file name it returns,
+      someone else may have beaten you to the punch.  :func:`mktemp` usage can
+      be replaced easily with :func:`NamedTemporaryFile`, passing it the
+      ``delete=False`` parameter::
 
          >>> f = NamedTemporaryFile(delete=False)
          >>> f
index 944687bb02c31f3356858a78987053a2d0b04a20..e1c25b63595914983177f04527493c8298270292 100644 (file)
@@ -22,15 +22,15 @@ classes.  In addition, the internal module :mod:`_tkinter` provides a threadsafe
 mechanism which allows Python and Tcl to interact.
 
 :mod:`Tkinter`'s chief virtues are that it is fast, and that it usually comes
-bundled with Python. Although its standard documentation is weak, good 
-material is available, which includes: references, tutorials, a book and 
-others. :mod:`Tkinter` is also famous for having an outdated look and feel, 
-which has been vastly improved in Tk 8.5. Nevertheless, there are many other 
-GUI libraries that you could be interested in. For more information about 
+bundled with Python. Although its standard documentation is weak, good
+material is available, which includes: references, tutorials, a book and
+others. :mod:`Tkinter` is also famous for having an outdated look and feel,
+which has been vastly improved in Tk 8.5. Nevertheless, there are many other
+GUI libraries that you could be interested in. For more information about
 alternatives, see the :ref:`other-gui-packages` section.
 
 .. toctree::
-   
+
    tkinter.rst
    tix.rst
    scrolledtext.rst
index 7695403d175777fced9cdc164a8e53235cba0158..ce8085d973bc33f4c3b46af5fd9f16e61bc5a0a1 100644 (file)
@@ -284,7 +284,7 @@ perform some *action*.  In C, you'd express this as someAction(fred,
 someOptions), in C++, you would express this as fred.someAction(someOptions),
 and in Tk, you say::
 
-   .fred someAction someOptions 
+   .fred someAction someOptions
 
 Note that the object name, ``.fred``, starts with a dot.
 
@@ -490,7 +490,7 @@ Packer Options
 For more extensive information on the packer and the options that it can take,
 see the man pages and page 183 of John Ousterhout's book.
 
-anchor 
+anchor
    Anchor type.  Denotes where the packer is to place each slave in its parcel.
 
 expand
@@ -720,7 +720,7 @@ event.  The following table lists the other event fields you can access, and how
 they are denoted in Tk, which can be useful when referring to the Tk man pages.
 ::
 
-   Tk      Tkinter Event Field             Tk      Tkinter Event Field 
+   Tk      Tkinter Event Field             Tk      Tkinter Event Field
    --      -------------------             --      -------------------
    %f      focus                           %A      char
    %h      height                          %E      send_event
index 05d5d660ccbe0865eccd44d226a11a1c60ec88dd..f79d7e5c8a8e3a0b9e7c23d2ddc97283887ddb60 100644 (file)
@@ -65,13 +65,13 @@ The following command-line arguments are supported:
 
 :option:`--ignore-module`
    Accepts comma separated list of module names. Ignore each of the named
-   module and its submodules (if it is a package).  May be given 
+   module and its submodules (if it is a package).  May be given
    multiple times.
 
 :option:`--ignore-dir`
    Ignore all modules and packages in the named directory and subdirectories
    (multiple directories can be joined by os.pathsep).  May be given multiple
-   times. 
+   times.
 
 
 .. _trace-api:
index d446339c70512328b7e4cb1904a36d2bf3aefcc1..126003785775b7d7b035e786fc82c9b65ba29436 100644 (file)
@@ -169,10 +169,10 @@ exception and traceback::
 
    def lumberjack():
        bright_side_of_death()
-   
+
    def bright_side_of_death():
        return tuple()[0]
-   
+
    try:
        lumberjack()
    except:
@@ -251,12 +251,12 @@ The following example shows the different ways to print and format the stack::
    >>> import traceback
    >>> def another_function():
    ...     lumberstack()
-   ... 
+   ...
    >>> def lumberstack():
    ...     traceback.print_stack()
    ...     print repr(traceback.extract_stack())
    ...     print repr(traceback.format_stack())
-   ... 
+   ...
    >>> another_function()
      File "<doctest>", line 10, in <module>
        another_function()
index 5f9bf184958bfa6117c4661eec00e5095718ad44..3155d87807068e9f9a154cefa871671b75f5b825 100644 (file)
@@ -1587,7 +1587,7 @@ The public classes of the module :mod:`turtle`
 
    Subclass of TurtleScreen, with :ref:`four methods added <screenspecific>`.
 
-   
+
 .. class:: ScrolledCavas(master)
 
    :param master: some Tkinter widget to contain the ScrolledCanvas, i.e.
@@ -1612,13 +1612,13 @@ The public classes of the module :mod:`turtle`
    "compound"  ``None`` (a compund shape has to be constructed using the
                :meth:`addcomponent` method)
    =========== ===========
-                
+
    .. method:: addcomponent(poly, fill, outline=None)
 
       :param poly: a polygon, i.e. a tuple of pairs of numbers
       :param fill: a color the *poly* will be filled with
       :param outline: a color for the poly's outline (if given)
-     
+
       Example:
 
       >>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
@@ -1662,31 +1662,31 @@ facilities:
 
      >>> help(Screen.bgcolor)
      Help on method bgcolor in module turtle:
-    
+
      bgcolor(self, *args) unbound turtle.Screen method
          Set or return backgroundcolor of the TurtleScreen.
-    
+
          Arguments (if given): a color string or three numbers
          in the range 0..colormode or a 3-tuple of such numbers.
-    
-    
+
+
            >>> screen.bgcolor("orange")
            >>> screen.bgcolor()
            "orange"
            >>> screen.bgcolor(0.5,0,0.5)
            >>> screen.bgcolor()
            "#800080"
-    
+
      >>> help(Turtle.penup)
      Help on method penup in module turtle:
-    
+
      penup(self) unbound turtle.Turtle method
          Pull the pen up -- no drawing when moving.
-    
+
          Aliases: penup | pu | up
-    
+
          No argument
-    
+
          >>> turtle.penup()
 
 - The docstrings of the functions which are derived from methods have a modified
@@ -1694,32 +1694,32 @@ facilities:
 
      >>> help(bgcolor)
      Help on function bgcolor in module turtle:
-    
+
      bgcolor(*args)
          Set or return backgroundcolor of the TurtleScreen.
-    
+
          Arguments (if given): a color string or three numbers
          in the range 0..colormode or a 3-tuple of such numbers.
-    
+
          Example::
-    
+
            >>> bgcolor("orange")
            >>> bgcolor()
            "orange"
            >>> bgcolor(0.5,0,0.5)
            >>> bgcolor()
            "#800080"
-    
+
      >>> help(penup)
      Help on function penup in module turtle:
-    
+
      penup()
          Pull the pen up -- no drawing when moving.
-    
+
          Aliases: penup | pu | up
-    
+
          No argument
-    
+
          Example:
          >>> penup()
 
index 09c61d267c824aa3163eaea3ffd5a9dbef5f1f64..ac646c5f303dda05d7f7ae8563eebd678041f967 100644 (file)
@@ -21,7 +21,7 @@ Some of these are very old and/or not very robust; marked with "hmm."
 
 :mod:`ihooks`
    --- Import hook support (for :mod:`rexec`; may become obsolete).
-   
+
    .. warning:: The :mod:`ihooks` module has been removed in Python 3.0.
 
 
@@ -54,7 +54,7 @@ Multimedia
 :mod:`linuxaudiodev`
    --- Play audio data on the Linux audio device.  Replaced in Python 2.3 by the
    :mod:`ossaudiodev` module.
-   
+
    .. warning:: The :mod:`linuxaudiodev` module has been removed in Python 3.0.
 
 :mod:`sunaudio`
@@ -240,7 +240,7 @@ extensions.
 
 :mod:`timing`
    --- Measure time intervals to high resolution (use :func:`time.clock` instead).
-   
+
    .. warning:: The :mod:`timing` module has been removed in Python 3.0.
 
 
@@ -255,6 +255,6 @@ of reality.
 
 :mod:`sv`
    --- Interface to the "simple video" board on SGI Indigo (obsolete hardware).
-   
+
    .. warning:: The :mod:`sv` module has been removed in Python 3.0.
 
index 83f4604ef70be37b41d465138adf12b5ffe5e82f..440a1350a894b63f190040735df7182675db6106 100644 (file)
@@ -164,7 +164,7 @@ Examples:
      File "<stdin>", line 1, in ?
    ValueError: not a decimal
    >>> unicodedata.category(u'A')  # 'L'etter, 'u'ppercase
-   'Lu'   
+   'Lu'
    >>> unicodedata.bidirectional(u'\u0660') # 'A'rabic, 'N'umber
    'AN'
 
index 792a98e8c714ee1156f453f88004bbab9fcfa02e..1a1b1d86fe75e5fceda1853d45fa5199a3425d62 100644 (file)
@@ -595,7 +595,7 @@ failures.
             TestCase.failUnlessAlmostEqual(first, second[, places[, msg]])
 
    Test that *first* and *second* are approximately equal by computing the
-   difference, rounding to the given number of decimal *places* (default 7), 
+   difference, rounding to the given number of decimal *places* (default 7),
    and comparing to zero.
    Note that comparing a given number of decimal places is not the same as
    comparing a given number of significant digits. If the values do not compare
@@ -606,7 +606,7 @@ failures.
             TestCase.failIfAlmostEqual(first, second[, places[, msg]])
 
    Test that *first* and *second* are not approximately equal by computing the
-   difference, rounding to the given number of decimal *places* (default 7), 
+   difference, rounding to the given number of decimal *places* (default 7),
    and comparing to zero.
    Note that comparing a given number of decimal places is not the same as
    comparing a given number of significant digits. If the values do not compare
index b2f96a19b43577a8bbcd490b04f3b0a3d8813857..1d02b1cdd01ef0b35ae15b943bce71bddb77a418 100644 (file)
@@ -123,7 +123,7 @@ High-level interface
    .. versionchanged:: 2.6
       Added :meth:`getcode` to returned object and support for the
       :envvar:`no_proxy` environment variable.
-      
+
    .. deprecated:: 2.6
       The :func:`urlopen` function has been removed in Python 3.0 in favor
       of :func:`urllib2.urlopen`.
index 4c7c5829089de9c59174e1d315770582eb456d85..986e545737b930815a0ffadac424d90fab5e0910 100644 (file)
@@ -109,7 +109,7 @@ The following exceptions are raised as appropriate:
 
    .. attribute:: code
 
-      An HTTP status code as defined in `RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html>`_. 
+      An HTTP status code as defined in `RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html>`_.
       This numeric value corresponds to a value found in the dictionary of
       codes as found in :attr:`BaseHTTPServer.BaseHTTPRequestHandler.responses`.
 
index e7ed0f1051801bd086df8c0c14fcb81c81681a1d..40f889b47d9fa07e109893197ab7077a4e8e18df 100644 (file)
@@ -290,7 +290,7 @@ described in those functions, as well as provide an additional method:
 
    .. versionadded:: 2.5
 
-The following classes provide the implementations of the parse results::
+The following classes provide the implementations of the parse results:
 
 
 .. class:: BaseResult
index bb3aa44da592ae68f9307327b8dd8315ba863f36..81e74528305b8f22df5c0413e0e67f2b03d41aa5 100644 (file)
@@ -274,7 +274,7 @@ Available Functions
 
 .. function:: warnpy3k(message[, category[, stacklevel]])
 
-   Issue a warning related to Python 3.x deprecation. Warnings are only shown 
+   Issue a warning related to Python 3.x deprecation. Warnings are only shown
    when Python is started with the -3 option. Like :func:`warn` *message* must
    be a string and *category* a subclass of :exc:`Warning`. :func:`warnpy3k`
    is using :exc:`DeprecationWarning` as default warning class.
@@ -288,7 +288,7 @@ Available Functions
    this function with an alternative implementation by assigning to
    ``warnings.showwarning``.
    *line* is a line of source code to be included in the warning
-   message; if *line* is not supplied, :func:`showwarning` will 
+   message; if *line* is not supplied, :func:`showwarning` will
    try to read the line specified by *filename* and *lineno*.
 
    .. versionchanged:: 2.6
@@ -299,8 +299,8 @@ Available Functions
 .. function:: formatwarning(message, category, filename, lineno[, line])
 
    Format a warning the standard way.  This returns a string  which may contain
-   embedded newlines and ends in a newline.  *line* is 
-   a line of source code to be included in the warning message; if *line* is not supplied, 
+   embedded newlines and ends in a newline.  *line* is
+   a line of source code to be included in the warning message; if *line* is not supplied,
    :func:`formatwarning` will try to read the line specified by *filename* and *lineno*.
 
    .. versionchanged:: 2.6
index d340b8a528cf01896ea2e502065a4c084ffeafe7..4d819e6c9e091f9dd802cb8af5b1ba105965bb11 100644 (file)
@@ -160,7 +160,7 @@ Here are some simple examples::
 
    url = 'http://www.python.org'
 
-   # Open URL in a new tab, if a browser window is already open. 
+   # Open URL in a new tab, if a browser window is already open.
    webbrowser.open_new_tab(url + '/doc')
 
    # Open URL in new window, raising the window if possible.
index a888bf96a57e62f281953ebb064362694d9211bb..a97eaecbbf233b0f8ea3920f0a65e9c0fd4bf540 100644 (file)
@@ -170,7 +170,7 @@ also provides these miscellaneous utilities:
       filelike = StringIO("This is an example file-like object"*10)
       wrapper = FileWrapper(filelike, blksize=5)
 
-      for chunk in wrapper: 
+      for chunk in wrapper:
           print chunk
 
 
@@ -415,7 +415,7 @@ Paste" library.
       from wsgiref.validate import validator
       from wsgiref.simple_server import make_server
 
-      # Our callable object which is intentionally not compliant to the 
+      # Our callable object which is intentionally not compliant to the
       # standard, so the validator is going to break
       def simple_app(environ, start_response):
           status = '200 OK' # HTTP Status
index b17d5103aa113c994263e65c3fdf239f83bc093f..9aa1ea3b3f17b2e7e930d1c25efdeb87d1ac3a0a 100644 (file)
@@ -34,7 +34,7 @@ convert it from and to XML.
 A C implementation of this API is available as :mod:`xml.etree.cElementTree`.
 
 See http://effbot.org/zone/element-index.htm for tutorials and links to other
-docs. Fredrik Lundh's page is also the location of the development version of the 
+docs. Fredrik Lundh's page is also the location of the development version of the
 xml.etree.ElementTree.
 
 .. _elementtree-functions:
@@ -379,7 +379,7 @@ This is the XML file that is going to be manipulated::
             <title>Example page</title>
         </head>
         <body>
-            <p>Moved to <a href="http://example.org/">example.org</a> 
+            <p>Moved to <a href="http://example.org/">example.org</a>
             or <a href="http://example.com/">example.com</a>.</p>
         </body>
     </html>
@@ -486,9 +486,9 @@ XMLTreeBuilder Objects
 
 :meth:`XMLTreeBuilder.feed` calls *target*\'s :meth:`start` method
 for each opening tag, its :meth:`end` method for each closing tag,
-and data is processed by method :meth:`data`. :meth:`XMLTreeBuilder.close` 
-calls *target*\'s method :meth:`close`. 
-:class:`XMLTreeBuilder` can be used not only for building a tree structure. 
+and data is processed by method :meth:`data`. :meth:`XMLTreeBuilder.close`
+calls *target*\'s method :meth:`close`.
+:class:`XMLTreeBuilder` can be used not only for building a tree structure.
 This is an example of counting the maximum depth of an XML file::
 
     >>> from xml.etree.ElementTree import XMLTreeBuilder
@@ -496,16 +496,16 @@ This is an example of counting the maximum depth of an XML file::
     ...     maxDepth = 0
     ...     depth = 0
     ...     def start(self, tag, attrib):   # Called for each opening tag.
-    ...         self.depth += 1 
+    ...         self.depth += 1
     ...         if self.depth > self.maxDepth:
     ...             self.maxDepth = self.depth
     ...     def end(self, tag):             # Called for each closing tag.
     ...         self.depth -= 1
-    ...     def data(self, data):   
+    ...     def data(self, data):
     ...         pass            # We do not need to do anything with data.
     ...     def close(self):    # Called when all data has been parsed.
     ...         return self.maxDepth
-    ... 
+    ...
     >>> target = MaxDepth()
     >>> parser = XMLTreeBuilder(target=target)
     >>> exampleXml = """
index a227c4728b16841938f435423eb71f7df9a6c052..039a8a8d5ace83fcb05b0904d364c7189db62f5f 100644 (file)
@@ -560,8 +560,8 @@ transport.  The following example shows how:
            self.proxy = proxy
        def make_connection(self, host):
            self.realhost = host
-       h = httplib.HTTP(self.proxy)
-       return h
+           h = httplib.HTTP(self.proxy)
+           return h
        def send_request(self, connection, handler, request_body):
            connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
        def send_host(self, connection, host):
index 7ba5ffe04c75fd6e7f9d38f25cec166b05105543..d282a5576923ce1f2c362d4fb0236bce3c967fa6 100644 (file)
@@ -200,7 +200,7 @@ ZipFile Objects
 
 .. method:: ZipFile.extractall([path[, members[, pwd]]])
 
-   Extract all members from the archive to the current working directory.  *path* 
+   Extract all members from the archive to the current working directory.  *path*
    specifies a different directory to extract to.  *members* is optional and must
    be a subset of the list returned by :meth:`namelist`.  *pwd* is the password
    used for encrypted files.
@@ -280,9 +280,9 @@ ZipFile Objects
 
    .. note::
 
-      When passing a :class:`ZipInfo` instance as the *zinfo_or_acrname* parameter, 
-      the compression method used will be that specified in the *compress_type* 
-      member of the given :class:`ZipInfo` instance.  By default, the 
+      When passing a :class:`ZipInfo` instance as the *zinfo_or_acrname* parameter,
+      the compression method used will be that specified in the *compress_type*
+      member of the given :class:`ZipInfo` instance.  By default, the
       :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`.
 
 The following data attributes are also available:
@@ -296,9 +296,9 @@ The following data attributes are also available:
 
 .. attribute:: ZipFile.comment
 
-   The comment text associated with the ZIP file.  If assigning a comment to a 
-   :class:`ZipFile` instance created with mode 'a' or 'w', this should be a 
-   string no longer than 65535 bytes.  Comments longer than this will be 
+   The comment text associated with the ZIP file.  If assigning a comment to a
+   :class:`ZipFile` instance created with mode 'a' or 'w', this should be a
+   string no longer than 65535 bytes.  Comments longer than this will be
    truncated in the written archive when :meth:`ZipFile.close` is called.
 
 .. _pyzipfile-objects:
@@ -327,10 +327,10 @@ The :class:`PyZipFile` constructor takes the same parameters as the
    internal use only.  The :meth:`writepy` method makes archives with file names
    like this::
 
-      string.pyc                                # Top level name 
-      test/__init__.pyc                         # Package directory 
+      string.pyc                                # Top level name
+      test/__init__.pyc                         # Package directory
       test/test_support.pyc                          # Module test.test_support
-      test/bogus/__init__.pyc                   # Subpackage directory 
+      test/bogus/__init__.pyc                   # Subpackage directory
       test/bogus/myfile.pyc                     # Submodule test.bogus.myfile
 
 
index 104182e7e8c5ae9351f1dfb56cbc08be1b97d8e3..0a6ece095c09be82fb55fe8243a8599ba1317841 100644 (file)
@@ -148,7 +148,7 @@ Here is an example that imports a module from a ZIP archive - note that the
     --------                   -------
         8467                   1 file
    $ ./python
-   Python 2.3 (#1, Aug 1 2003, 19:54:32) 
+   Python 2.3 (#1, Aug 1 2003, 19:54:32)
    >>> import sys
    >>> sys.path.insert(0, '/tmp/example.zip')  # Add .zip file to front of path
    >>> import jwzthreading
index a1742e521c9e03cb87a723a4ef43a7c3c9cfb874..278bb2d84338d2f0e60a7b505534c02b4378987b 100644 (file)
@@ -124,7 +124,7 @@ Terms and conditions for accessing or otherwise using Python
    analyze, test, perform and/or display publicly, prepare derivative works,
    distribute, and otherwise use Python |release| alone or in any derivative
    version, provided, however, that PSF's License Agreement and PSF's notice of
-   copyright, i.e., "Copyright Â© 2001-2008 Python Software Foundation; All Rights
+   copyright, i.e., "Copyright Â© 2001-2009 Python Software Foundation; All Rights
    Reserved" are retained in Python |release| alone or in any derivative version
    prepared by Licensee.
 
@@ -386,8 +386,8 @@ Floating point exception control
 
 The source for the :mod:`fpectl` module includes the following notice::
 
-     ---------------------------------------------------------------------  
-    /                       Copyright (c) 1996.                           \ 
+     ---------------------------------------------------------------------
+    /                       Copyright (c) 1996.                           \
    |          The Regents of the University of California.                 |
    |                        All rights reserved.                           |
    |                                                                       |
@@ -419,7 +419,7 @@ The source for the :mod:`fpectl` module includes the following notice::
    |   opinions  of authors expressed herein do not necessarily state or   |
    |   reflect those of the United States Government or  the  University   |
    |   of  California,  and shall not be used for advertising or product   |
-    \  endorsement purposes.                                              / 
+    \  endorsement purposes.                                              /
      ---------------------------------------------------------------------
 
 
@@ -453,7 +453,7 @@ The source code for the :mod:`md5` module contains the following notice::
 
      This code implements the MD5 Algorithm defined in RFC 1321, whose
      text is available at
-       http://www.ietf.org/rfc/rfc1321.txt
+           http://www.ietf.org/rfc/rfc1321.txt
      The code is derived from the text of the RFC, including the test suite
      (section A.5) but excluding the rest of Appendix A.  It does not include
      any code or documentation that is identified in the RFC as being
@@ -464,12 +464,12 @@ The source code for the :mod:`md5` module contains the following notice::
      that follows (in reverse chronological order):
 
      2002-04-13 lpd Removed support for non-ANSI compilers; removed
-       references to Ghostscript; clarified derivation from RFC 1321;
-       now handles byte order either statically or dynamically.
+           references to Ghostscript; clarified derivation from RFC 1321;
+           now handles byte order either statically or dynamically.
      1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
      1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
-       added conditionalization for C++ compilation from Martin
-       Purschke <purschke@bnl.gov>.
+           added conditionalization for C++ compilation from Martin
+           Purschke <purschke@bnl.gov>.
      1999-05-03 lpd Original version.
 
 
index e5e40cf0a084b033793f786a52c85516ff1e266c..550644c9a6d113d79c8b4972c2431e8d59e530c8 100644 (file)
@@ -560,7 +560,7 @@ or list).  Slicings may be used as expressions or as targets in assignment or
 .. productionlist::
    slicing: `simple_slicing` | `extended_slicing`
    simple_slicing: `primary` "[" `short_slice` "]"
-   extended_slicing: `primary` "[" `slice_list` "]" 
+   extended_slicing: `primary` "[" `slice_list` "]"
    slice_list: `slice_item` ("," `slice_item`)* [","]
    slice_item: `expression` | `proper_slice` | `ellipsis`
    proper_slice: `short_slice` | `long_slice`
@@ -664,7 +664,7 @@ raised.  Otherwise, the list of filled slots is used as the argument list for
 the call.
 
 .. note::
-   
+
    An implementation may provide builtin functions whose positional parameters do
    not have names, even if they are 'named' for the purpose of documentation, and
    which therefore cannot be supplied by keyword.  In CPython, this is the case for
@@ -1321,7 +1321,7 @@ groups from right to left).
 .. rubric:: Footnotes
 
 .. [#] In Python 2.3 and later releases, a list comprehension "leaks" the control
-   variables of each ``for`` it contains into the containing scope.  However, this 
+   variables of each ``for`` it contains into the containing scope.  However, this
    behavior is deprecated, and relying on it will not work in Python 3.0
 
 .. [#] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it may not be
@@ -1354,7 +1354,7 @@ groups from right to left).
    only, but this caused surprises because people expected to be able to test a
    dictionary for emptiness by comparing it to ``{}``.
 
-.. [#] Due to automatic garbage-collection, free lists, and the dynamic nature of 
+.. [#] Due to automatic garbage-collection, free lists, and the dynamic nature of
    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.
index f05b91b66b637c18126a01444ed3dd47bee5ab74..21449eb373279442aa4e16c15acb74d700e7b7c9 100644 (file)
@@ -341,13 +341,13 @@ The following identifiers are used as reserved words, or *keywords* of the
 language, and cannot be used as ordinary identifiers.  They must be spelled
 exactly as written here::
 
-   and       del       from      not       while    
-   as        elif      global    or        with     
-   assert    else      if        pass      yield    
-   break     except    import    print              
-   class     exec      in        raise              
-   continue  finally   is        return             
-   def       for       lambda    try 
+   and       del       from      not       while
+   as        elif      global    or        with
+   assert    else      if        pass      yield
+   break     except    import    print
+   class     exec      in        raise
+   continue  finally   is        return
+   def       for       lambda    try
 
 .. versionchanged:: 2.4
    :const:`None` became a constant and is now recognized by the compiler as a name
@@ -654,7 +654,7 @@ Some examples of plain integer literals (first row) and long integer literals
 
    7     2147483647                        0177
    3L    79228162514264337593543950336L    0377L   0x100000000L
-         79228162514264337593543950336             0xdeadbeef                                              
+         79228162514264337593543950336             0xdeadbeef
 
 
 .. _floating:
@@ -701,7 +701,7 @@ restrictions on their range.  To create a complex number with a nonzero real
 part, add a floating point number to it, e.g., ``(3+4j)``.  Some examples of
 imaginary literals::
 
-   3.14j   10.j    10j     .001j   1e100j  3.14e-10j 
+   3.14j   10.j    10j     .001j   1e100j  3.14e-10j
 
 
 .. _operators:
index 183b776e3692318adac670e8baed51ea881ed491..d43ee8b864b7c6873686d502b7f5a18b175c6edc 100644 (file)
@@ -745,7 +745,7 @@ up to the last dot is used to find a "package"; the final identifier is then
 searched inside the package.  A package is generally a subdirectory of a
 directory on ``sys.path`` that has a file :file:`__init__.py`.
 
-.. 
+..
    [XXX Can't be
    bothered to spell this out right now; see the URL
    http://www.python.org/doc/essays/packages.html for more details, also about how
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py
new file mode 100755 (executable)
index 0000000..0846d2a
--- /dev/null
@@ -0,0 +1,230 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Check for stylistic and formal issues in .rst and .py
+# files included in the documentation.
+#
+# 01/2009, Georg Brandl
+
+from __future__ import with_statement
+
+import os
+import re
+import sys
+import getopt
+import subprocess
+from os.path import join, splitext, abspath, exists
+from collections import defaultdict
+
+directives = [
+    # standard docutils ones
+    'admonition', 'attention', 'caution', 'class', 'compound', 'container',
+    'contents', 'csv-table', 'danger', 'date', 'default-role', 'epigraph',
+    'error', 'figure', 'footer', 'header', 'highlights', 'hint', 'image',
+    'important', 'include', 'line-block', 'list-table', 'meta', 'note',
+    'parsed-literal', 'pull-quote', 'raw', 'replace',
+    'restructuredtext-test-directive', 'role', 'rubric', 'sectnum', 'sidebar',
+    'table', 'target-notes', 'tip', 'title', 'topic', 'unicode', 'warning',
+    # Sphinx custom ones
+    'acks', 'attribute', 'autoattribute', 'autoclass', 'autodata',
+    'autoexception', 'autofunction', 'automethod', 'automodule', 'centered',
+    'cfunction', 'class', 'classmethod', 'cmacro', 'cmdoption', 'cmember',
+    'code-block', 'confval', 'cssclass', 'ctype', 'currentmodule', 'cvar',
+    'data', 'deprecated', 'describe', 'directive', 'doctest', 'envvar', 'event',
+    'exception', 'function', 'glossary', 'highlight', 'highlightlang', 'index',
+    'literalinclude', 'method', 'module', 'moduleauthor', 'productionlist',
+    'program', 'role', 'sectionauthor', 'seealso', 'sourcecode', 'staticmethod',
+    'tabularcolumns', 'testcode', 'testoutput', 'testsetup', 'toctree', 'todo',
+    'todolist', 'versionadded', 'versionchanged'
+]
+
+all_directives = '(' + '|'.join(directives) + ')'
+seems_directive_re = re.compile(r'\.\. %s([^a-z:]|:(?!:))' % all_directives)
+default_role_re = re.compile(r'(^| )`\w([^`]*?\w)?`($| )')
+leaked_markup_re = re.compile(r'[a-z]::[^=]|:[a-z]+:|`|\.\.\s*\w+:')
+
+
+checkers = {}
+
+checker_props = {'severity': 1, 'falsepositives': False}
+
+def checker(*suffixes, **kwds):
+    """Decorator to register a function as a checker."""
+    def deco(func):
+        for suffix in suffixes:
+            checkers.setdefault(suffix, []).append(func)
+        for prop in checker_props:
+            setattr(func, prop, kwds.get(prop, checker_props[prop]))
+        return func
+    return deco
+
+
+@checker('.py', severity=4)
+def check_syntax(fn, lines):
+    """Check Python examples for valid syntax."""
+    try:
+        code = ''.join(lines)
+        if '\r' in code:
+            if os.name != 'nt':
+                yield 0, '\\r in code file'
+            code = code.replace('\r', '')
+        compile(code, fn, 'exec')
+    except SyntaxError, err:
+        yield err.lineno, 'not compilable: %s' % err
+
+
+@checker('.rst', severity=2)
+def check_suspicious_constructs(fn, lines):
+    """Check for suspicious reST constructs."""
+    inprod = False
+    for lno, line in enumerate(lines):
+        if seems_directive_re.match(line):
+            yield lno+1, 'comment seems to be intended as a directive'
+        if '.. productionlist::' in line:
+            inprod = True
+        elif not inprod and default_role_re.search(line):
+            yield lno+1, 'default role used'
+        elif inprod and not line.strip():
+            inprod = False
+
+
+@checker('.py', '.rst')
+def check_whitespace(fn, lines):
+    """Check for whitespace and line length issues."""
+    for lno, line in enumerate(lines):
+        if '\r' in line:
+            yield lno+1, '\\r in line'
+        if '\t' in line:
+            yield lno+1, 'OMG TABS!!!1'
+        if line[:-1].rstrip(' \t') != line[:-1]:
+            yield lno+1, 'trailing whitespace'
+
+
+@checker('.rst', severity=0)
+def check_line_length(fn, lines):
+    """Check for line length; this checker is not run by default."""
+    for lno, line in enumerate(lines):
+        if len(line) > 81:
+            # don't complain about tables, links and function signatures
+            if line.lstrip()[0] not in '+|' and \
+               'http://' not in line and \
+               not line.lstrip().startswith(('.. function',
+                                             '.. method',
+                                             '.. cfunction')):
+                yield lno+1, "line too long"
+
+
+@checker('.html', severity=2, falsepositives=True)
+def check_leaked_markup(fn, lines):
+    """Check HTML files for leaked reST markup; this only works if
+    the HTML files have been built.
+    """
+    for lno, line in enumerate(lines):
+        if leaked_markup_re.search(line):
+            yield lno+1, 'possibly leaked markup: %r' % line
+
+
+def main(argv):
+    usage = '''\
+Usage: %s [-v] [-f] [-s sev] [-i path]* [path]
+
+Options:  -v       verbose (print all checked file names)
+          -f       enable checkers that yield many false positives
+          -s sev   only show problems with severity >= sev
+          -i path  ignore subdir or file path
+''' % argv[0]
+    try:
+        gopts, args = getopt.getopt(argv[1:], 'vfs:i:')
+    except getopt.GetoptError:
+        print usage
+        return 2
+
+    verbose = False
+    severity = 1
+    ignore = []
+    falsepos = False
+    for opt, val in gopts:
+        if opt == '-v':
+            verbose = True
+        elif opt == '-f':
+            falsepos = True
+        elif opt == '-s':
+            severity = int(val)
+        elif opt == '-i':
+            ignore.append(abspath(val))
+
+    if len(args) == 0:
+        path = '.'
+    elif len(args) == 1:
+        path = args[0]
+    else:
+        print usage
+        return 2
+
+    if not exists(path):
+        print 'Error: path %s does not exist' % path
+        return 2
+
+    count = defaultdict(int)
+    out = sys.stdout
+
+    for root, dirs, files in os.walk(path):
+        # ignore subdirs controlled by svn
+        if '.svn' in dirs:
+            dirs.remove('.svn')
+
+        # ignore subdirs in ignore list
+        if abspath(root) in ignore:
+            del dirs[:]
+            continue
+
+        for fn in files:
+            fn = join(root, fn)
+            if fn[:2] == './':
+                fn = fn[2:]
+
+            # ignore files in ignore list
+            if abspath(fn) in ignore:
+                continue
+
+            ext = splitext(fn)[1]
+            checkerlist = checkers.get(ext, None)
+            if not checkerlist:
+                continue
+
+            if verbose:
+                print 'Checking %s...' % fn
+
+            try:
+                with open(fn, 'r') as f:
+                    lines = list(f)
+            except (IOError, OSError), err:
+                print '%s: cannot open: %s' % (fn, err)
+                count[4] += 1
+                continue
+
+            for checker in checkerlist:
+                if checker.falsepositives and not falsepos:
+                    continue
+                csev = checker.severity
+                if csev >= severity:
+                    for lno, msg in checker(fn, lines):
+                        print >>out, '[%d] %s:%d: %s' % (csev, fn, lno, msg)
+                        count[csev] += 1
+    if verbose:
+        print
+    if not count:
+        if severity > 1:
+            print 'No problems with severity >= %d found.' % severity
+        else:
+            print 'No problems found.'
+    else:
+        for severity in sorted(count):
+            number = count[severity]
+            print '%d problem%s with severity %d found.' % \
+                  (number, number > 1 and 's' or '', severity)
+    return int(bool(count))
+
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))
index 43f2c6da798816309da2d838e7ce77ec4927e17d..48c7bcb9acd18928beb67d8cb9012579b612a2bc 100644 (file)
@@ -250,7 +250,7 @@ are passed on to :meth:`__init__`.  For example, ::
    ...     def __init__(self, realpart, imagpart):
    ...         self.r = realpart
    ...         self.i = imagpart
-   ... 
+   ...
    >>> x = Complex(3.0, -4.5)
    >>> x.r, x.i
    (3.0, -4.5)
@@ -481,7 +481,7 @@ Python has two builtin functions that work with inheritance:
   ``issubclass(unicode, str)`` is ``False`` since :class:`unicode` is not a
   subclass of :class:`str` (they only share a common ancestor,
   :class:`basestring`).
-  
+
 
 
 .. _tut-multiple:
@@ -743,7 +743,7 @@ easy to create::
    f
    l
    o
-   g   
+   g
 
 Anything that can be done with generators can also be done with class based
 iterators as described in the previous section.  What makes generators so
index afc19e973eef4703f8ae40e7b899fe1caa43ae29..95a6ea4d2cba3cc4020bb782e0397072a103cbf3 100644 (file)
@@ -62,7 +62,7 @@ they appear in the sequence.  For example (no pun intended):
    ... a = ['cat', 'window', 'defenestrate']
    >>> for x in a:
    ...     print x, len(x)
-   ... 
+   ...
    cat 3
    window 6
    defenestrate 12
@@ -75,7 +75,7 @@ convenient::
 
    >>> for x in a[:]: # make a slice copy of the entire list
    ...    if len(x) > 6: a.insert(0, x)
-   ... 
+   ...
    >>> a
    ['defenestrate', 'cat', 'window', 'defenestrate']
 
@@ -110,7 +110,7 @@ To iterate over the indices of a sequence, you can combine :func:`range` and
    >>> a = ['Mary', 'had', 'a', 'little', 'lamb']
    >>> for i in range(len(a)):
    ...     print i, a[i]
-   ... 
+   ...
    0 Mary
    1 had
    2 a
@@ -146,7 +146,7 @@ following loop, which searches for prime numbers::
    ...     else:
    ...         # loop fell through without finding a factor
    ...         print n, 'is a prime number'
-   ... 
+   ...
    2 is a prime number
    3 is a prime number
    4 equals 2 * 2
@@ -167,7 +167,7 @@ required syntactically but the program requires no action. For example::
 
    >>> while True:
    ...     pass  # Busy-wait for keyboard interrupt (Ctrl+C)
-   ... 
+   ...
 
 This is commonly used for creating minimal classes::
 
@@ -181,7 +181,7 @@ at a more abstract level.  The :keyword:`pass` is silently ignored::
 
    >>> def initlog(*args):
    ...     pass   # Remember to implement this!
-   ... 
+   ...
 
 .. _tut-functions:
 
@@ -197,7 +197,7 @@ boundary::
    ...     while b < n:
    ...         print b,
    ...         a, b = b, a+b
-   ... 
+   ...
    >>> # Now call the function we just defined:
    ... fib(2000)
    1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
@@ -268,7 +268,7 @@ Fibonacci series, instead of printing it::
    ...         result.append(b)    # see below
    ...         a, b = b, a+b
    ...     return result
-   ... 
+   ...
    >>> f100 = fib2(100)    # call it
    >>> f100                # write the result
    [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
@@ -403,7 +403,7 @@ calls. Here's an example that fails due to this restriction::
 
    >>> def function(a):
    ...     pass
-   ... 
+   ...
    >>> function(0, a=0)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
@@ -456,7 +456,7 @@ Arbitrary Argument Lists
 ------------------------
 
 .. index::
-  statement: *  
+  statement: *
 
 Finally, the least frequently used option is to specify that a function can be
 called with an arbitrary number of arguments.  These arguments will be wrapped
@@ -565,11 +565,11 @@ Here is an example of a multi-line docstring::
 
    >>> def my_function():
    ...     """Do nothing, but document it.
-   ... 
+   ...
    ...     No, really, it doesn't do anything.
    ...     """
    ...     pass
-   ... 
+   ...
    >>> print my_function.__doc__
    Do nothing, but document it.
 
index fa718702496b1e0f8d250d76f9f64feb90196a51..2cc1e601c4c09f070adc1308e3917801f97627ff 100644 (file)
@@ -214,7 +214,7 @@ and the next item, and so on.  For example, ::
    >>> def sum(seq):
    ...     def add(x,y): return x+y
    ...     return reduce(add, seq, 0)
-   ... 
+   ...
    >>> sum(range(1, 11))
    55
    >>> sum([])
@@ -251,7 +251,7 @@ would evaluate to a tuple, it must be parenthesized. ::
    []
    >>> [[x,x**2] for x in vec]
    [[2, 4], [4, 16], [6, 36]]
-   >>> [x, x**2 for x in vec]  # error - parens required for tuples
+   >>> [x, x**2 for x in vec]  # error - parens required for tuples
      File "<stdin>", line 1, in ?
        [x, x**2 for x in vec]
                   ^
@@ -281,7 +281,7 @@ If you've got the stomach for it, list comprehensions can be nested. They are a
 powerful tool but -- like all powerful tools -- they need to be used carefully,
 if at all.
 
-Consider the following example of a 3x3 matrix held as a list containing three 
+Consider the following example of a 3x3 matrix held as a list containing three
 lists, one list per row::
 
     >>> mat = [
@@ -290,7 +290,7 @@ lists, one list per row::
     ...        [7, 8, 9],
     ...       ]
 
-Now, if you wanted to swap rows and columns, you could use a list 
+Now, if you wanted to swap rows and columns, you could use a list
 comprehension::
 
     >>> print [[row[i] for row in mat] for i in [0, 1, 2]]
@@ -308,7 +308,7 @@ A more verbose version of this snippet shows the flow explicitly::
             print row[i],
         print
 
-In real world, you should prefer builtin functions to complex flow statements. 
+In real world, you should prefer builtin functions to complex flow statements.
 The :func:`zip` function would do a great job for this use case::
 
     >>> zip(*mat)
@@ -551,7 +551,7 @@ with the :func:`zip` function. ::
    >>> answers = ['lancelot', 'the holy grail', 'blue']
    >>> for q, a in zip(questions, answers):
    ...     print 'What is your {0}?  It is {1}.'.format(q, a)
-   ... 
+   ...
    What is your name?  It is lancelot.
    What is your quest?  It is the holy grail.
    What is your favorite color?  It is blue.
@@ -574,7 +574,7 @@ returns a new sorted list while leaving the source unaltered. ::
    >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
    >>> for f in sorted(set(basket)):
    ...     print f
-   ...         
+   ...
    apple
    banana
    orange
index 1740396567c0d7fa86d07a992ccb3ee6a8d6bded..e1d988ccd6f0b725bd3e40059903e35869a4e65c 100644 (file)
@@ -91,7 +91,7 @@ is signalled by raising the :exc:`KeyboardInterrupt` exception. ::
    ...         break
    ...     except ValueError:
    ...         print "Oops!  That was no valid number.  Try again..."
-   ...     
+   ...
 
 The :keyword:`try` statement works as follows.
 
@@ -199,12 +199,12 @@ indirectly) in the try clause. For example::
 
    >>> def this_fails():
    ...     x = 1/0
-   ... 
+   ...
    >>> try:
    ...     this_fails()
    ... except ZeroDivisionError as detail:
    ...     print 'Handling run-time error:', detail
-   ... 
+   ...
    Handling run-time error: integer division or modulo by zero
 
 
@@ -256,12 +256,12 @@ directly or indirectly.  For example::
    ...         self.value = value
    ...     def __str__(self):
    ...         return repr(self.value)
-   ... 
+   ...
    >>> try:
    ...     raise MyError(2*2)
    ... except MyError as e:
    ...     print 'My exception occurred, value:', e.value
-   ... 
+   ...
    My exception occurred, value: 4
    >>> raise MyError, 'oops!'
    Traceback (most recent call last):
@@ -331,7 +331,7 @@ example::
    ...     raise KeyboardInterrupt
    ... finally:
    ...     print 'Goodbye, world!'
-   ... 
+   ...
    Goodbye, world!
    Traceback (most recent call last):
      File "<stdin>", line 2, in ?
index 3c0d91d3a373b03009d281db8bcadb73348a0508..dfc6ac0b0526580df774855c9c8ec109651f44d8 100644 (file)
@@ -1,7 +1,7 @@
 .. _tutorial-index:
 
 ######################
-  The Python Tutorial 
+  The Python Tutorial
 ######################
 
 :Release: |version|
index 7287e3e7846e3bc1eb86f6d1b6284ff3a981bcb4..34d984a5471ea98495c7ca161e2e46be2611f435 100644 (file)
@@ -87,7 +87,7 @@ Here are two ways to write a table of squares and cubes::
 
    >>> for x in range(1,11):
    ...     print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x)
-   ... 
+   ...
     1   1    1
     2   4    8
     3   9   27
@@ -148,7 +148,7 @@ Positional and keyword arguments can be arbitrarily combined::
    ...                                                    other='Georg')
    The story of Bill, Manfred, and Georg.
 
-An optional ``':``` and format specifier can follow the field name. This also
+An optional ``':'`` and format specifier can follow the field name. This also
 greater control over how the value is formatted.  The following example
 truncates the Pi to three places after the decimal.
 
@@ -162,7 +162,7 @@ number of characters wide.  This is useful for making tables pretty.::
    >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}
    >>> for name, phone in table.items():
    ...     print '{0:10} ==> {1:10d}'.format(name, phone)
-   ... 
+   ...
    Jack       ==>       4098
    Dcab       ==>       7678
    Sjoerd     ==>       4127
@@ -330,7 +330,7 @@ beginning of the file as the reference point. ::
    >>> f = open('/tmp/workfile', 'r+')
    >>> f.write('0123456789abcdef')
    >>> f.seek(5)     # Go to the 6th byte in the file
-   >>> f.read(1)        
+   >>> f.read(1)
    '5'
    >>> f.seek(-3, 2) # Go to the 3rd byte before the end
    >>> f.read(1)
index 0ac7ee11f6b0213730aa657bc939e4d39b57e3ef..1511584e6de30064644ec48558e09f37d9b62620 100644 (file)
@@ -112,7 +112,7 @@ example, take a look at this :keyword:`if` statement::
    >>> the_world_is_flat = 1
    >>> if the_world_is_flat:
    ...     print "Be careful not to fall off!"
-   ... 
+   ...
    Be careful not to fall off!
 
 
@@ -180,7 +180,7 @@ It is possible to use encodings different than ASCII in Python source files. The
 best way to do it is to put one more special comment line right after the ``#!``
 line to define the source file encoding::
 
-   # -*- coding: encoding -*- 
+   # -*- coding: encoding -*-
 
 
 With that declaration, all characters in the source file will be treated as
index 797e531270fc94a75872f730507bb61932bbd657..99e82a38e5cffe4a2e61ba1d2560fa9442177e93 100644 (file)
@@ -84,7 +84,7 @@ error will occur::
 
    >>> # try to access an undefined variable
    ... n
-   Traceback (most recent call last):   
+   Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'n' is not defined
 
@@ -219,14 +219,14 @@ Or, strings can be surrounded in a pair of matching triple-quotes: ``"""`` or
 they will be included in the string. ::
 
    print """
-   Usage: thingy [OPTIONS] 
+   Usage: thingy [OPTIONS]
         -h                        Display this usage message
         -H hostname               Hostname to connect to
    """
 
 produces the following output::
 
-   Usage: thingy [OPTIONS] 
+   Usage: thingy [OPTIONS]
         -h                        Display this usage message
         -H hostname               Hostname to connect to
 
@@ -350,10 +350,10 @@ One way to remember how slices work is to think of the indices as pointing
 Then the right edge of the last character of a string of *n* characters has
 index *n*, for example::
 
-    +---+---+---+---+---+ 
+    +---+---+---+---+---+
     | H | e | l | p | A |
-    +---+---+---+---+---+ 
-    0   1   2   3   4   5 
+    +---+---+---+---+---+
+    0   1   2   3   4   5
    -5  -4  -3  -2  -1
 
 The first row of numbers gives the position of the indices 0...5 in the string;
@@ -595,7 +595,7 @@ series as follows::
    >>> while b < 10:
    ...     print b
    ...     a, b = b, a+b
-   ... 
+   ...
    1
    1
    2
@@ -645,7 +645,7 @@ This example introduces several new features.
      >>> while b < 1000:
      ...     print b,
      ...     a, b = b, a+b
-     ... 
+     ...
      1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
 
   Note that the interpreter inserts a newline before it prints the next prompt if
index 7a5af4ffdbc411c6636d0734944b1ea93fb6bbce..f147cea493d560cf90d1d67e26a1f23618d81485 100644 (file)
@@ -281,7 +281,7 @@ defines.  It returns a sorted list of strings::
    ['__name__', 'fib', 'fib2']
    >>> dir(sys)
    ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__',
-    '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', 
+    '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv',
     'builtin_module_names', 'byteorder', 'callstats', 'copyright',
     'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook',
     'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags',
@@ -314,7 +314,7 @@ want a list of those, they are defined in the standard module
     'FloatingPointError', 'FutureWarning', 'IOError', 'ImportError',
     'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
     'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
-    'NotImplementedError', 'OSError', 'OverflowError', 
+    'NotImplementedError', 'OSError', 'OverflowError',
     'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError',
     'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError',
     'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True',
index 38e0871e129421f6b90865c0372740577d56d28b..8cd5d0a10a450906ac0a186c4d2a34c0167aad54 100644 (file)
@@ -136,7 +136,7 @@ The :mod:`random` module provides tools for making random selections::
    >>> random.random()    # random float
    0.17970987693706186
    >>> random.randrange(6)    # random integer chosen from range(6)
-   4   
+   4
 
 
 .. _tut-internet-access:
index abcf96a9d8e737836a1b782153b63b2b0b49cea3..8faa3604640c93981cdb2ee6535aa7c42bc9d974 100644 (file)
@@ -62,7 +62,7 @@ formatting numbers with group separators::
    >>> locale.format("%d", x, grouping=True)
    '1,234,567'
    >>> locale.format("%s%.*f", (conv['currency_symbol'],
-   ...       conv['frac_digits'], x), grouping=True)
+   ...               conv['frac_digits'], x), grouping=True)
    '$1,234,567.80'
 
 
index 43b5e83fc54b2dceb1299ae3b188637f817dcbc6..157cc9fec2c59c3a086e37ca6844f4988d8e6206 100644 (file)
@@ -63,6 +63,6 @@ solution for your problem.
 
 .. Postings figure based on average of last six months activity as
    reported by www.egroups.com; Jan. 2000 - June 2000: 21272 msgs / 182
-   days = 116.9 msgs / day and steadily increasing. (XXX up to date figures?) 
+   days = 116.9 msgs / day and steadily increasing. (XXX up to date figures?)
 
 
index 954df895b8c1779f30c16f0c8897123264ceb02f..643464b065d5759548a7168af74263396c111d14 100644 (file)
@@ -8,8 +8,8 @@ Command line and environment
 The CPython interpreter scans the command line and the environment for various
 settings.
 
-.. note:: 
-   
+.. note::
+
    Other implementations' command line schemes may differ.  See
    :ref:`implementations` for further resources.
 
@@ -61,7 +61,7 @@ source.
    Execute the Python code in *command*.  *command* can be one ore more
    statements separated by newlines, with significant leading whitespace as in
    normal module code.
-   
+
    If this option is given, the first element of :data:`sys.argv` will be
    ``"-c"`` and the current directory will be added to the start of
    :data:`sys.path` (allowing modules in that directory to be imported as top
@@ -72,7 +72,7 @@ source.
 
    Search :data:`sys.path` for the named module and execute its contents as
    the :mod:`__main__` module.
-   
+
    Since the argument is a *module* name, you must not give a file extension
    (``.py``).  The ``module-name`` should be a valid Python module name, but
    the implementation may not always enforce this (e.g. it may allow you to
@@ -84,18 +84,18 @@ source.
       written in C, since they do not have Python module files. However, it
       can still be used for precompiled modules, even if the original source
       file is not available.
-   
+
    If this option is given, the first element of :data:`sys.argv` will be the
    full path to the module file. As with the :option:`-c` option, the current
    directory will be added to the start of :data:`sys.path`.
-   
+
    Many standard library modules contain code that is invoked on their execution
    as a script.  An example is the :mod:`timeit` module::
 
        python -mtimeit -s 'setup here' 'benchmarked code here'
        python -mtimeit -h # for details
 
-   .. seealso:: 
+   .. seealso::
       :func:`runpy.run_module`
          The actual implementation of this feature.
 
@@ -163,7 +163,7 @@ Generic options
                --version
 
    Print the Python version number and exit.  Example output could be::
-    
+
        Python 2.5.1
 
    .. versionchanged:: 2.5
@@ -201,7 +201,7 @@ Miscellaneous options
    enter interactive mode after executing the script or the command, even when
    :data:`sys.stdin` does not appear to be a terminal.  The
    :envvar:`PYTHONSTARTUP` file is not read.
-   
+
    This can be useful to inspect global variables or a stack trace when a script
    raises an exception.  See also :envvar:`PYTHONINSPECT`.
 
@@ -221,7 +221,7 @@ Miscellaneous options
 .. cmdoption:: -Q <arg>
 
    Division control. The argument must be one of the following:
-   
+
    ``old``
      division of int/int and long/long return an int or long (*default*)
    ``new``
@@ -264,10 +264,10 @@ Miscellaneous options
 
 
 .. cmdoption:: -u
-   
+
    Force stdin, stdout and stderr to be totally unbuffered.  On systems where it
    matters, also put stdin, stdout and stderr in binary mode.
-   
+
    Note that there is internal buffering in :meth:`file.readlines` and
    :ref:`bltin-file-objects` (``for line in sys.stdin``) which is not influenced
    by this option.  To work around this, you will want to use
@@ -279,7 +279,7 @@ Miscellaneous options
 .. XXX should the -U option be documented?
 
 .. cmdoption:: -v
-   
+
    Print a message each time a module is initialized, showing the place
    (filename or built-in module) from which it is loaded.  When given twice
    (:option:`-vv`), print a message for each file that is checked for when
@@ -288,13 +288,13 @@ Miscellaneous options
 
 
 .. cmdoption:: -W arg
-   
+
    Warning control.  Python's warning machinery by default prints warning
    messages to :data:`sys.stderr`.  A typical warning message has the following
    form::
 
        file:line: category: message
-       
+
    By default, each warning is printed once for each source line where it
    occurs.  This option controls how often warnings are printed.
 
@@ -302,13 +302,13 @@ Miscellaneous options
    one option, the action for the last matching option is performed.  Invalid
    :option:`-W` options are ignored (though, a warning message is printed about
    invalid options when the first warning is issued).
-   
+
    Warnings can also be controlled from within a Python program using the
    :mod:`warnings` module.
 
    The simplest form of argument is one of the following action strings (or a
    unique abbreviation):
-    
+
    ``ignore``
       Ignore all warnings.
    ``default``
@@ -324,9 +324,9 @@ Miscellaneous options
       Print each warning only the first time it occurs in the program.
    ``error``
       Raise an exception instead of printing a warning message.
-      
-   The full form of argument is:: 
-   
+
+   The full form of argument is::
+
        action:message:category:module:line
 
    Here, *action* is as explained above but only applies to messages that match
@@ -347,10 +347,10 @@ Miscellaneous options
 
 
 .. cmdoption:: -x
-   
+
    Skip the first line of the source, allowing use of non-Unix forms of
    ``#!cmd``.  This is intended for a DOS specific hack only.
-   
+
    .. warning:: The line numbers in error messages will be off by one!
 
 
@@ -380,13 +380,13 @@ Environment variables
 These environment variables influence Python's behavior.
 
 .. envvar:: PYTHONHOME
-   
+
    Change the location of the standard Python libraries.  By default, the
    libraries are searched in :file:`{prefix}/lib/python{version}` and
    :file:`{exec_prefix}/lib/python{version}`, where :file:`{prefix}` and
    :file:`{exec_prefix}` are installation-dependent directories, both defaulting
    to :file:`/usr/local`.
-   
+
    When :envvar:`PYTHONHOME` is set to a single directory, its value replaces
    both :file:`{prefix}` and :file:`{exec_prefix}`.  To specify different values
    for these, set :envvar:`PYTHONHOME` to :file:`{prefix}:{exec_prefix}`.
@@ -402,11 +402,11 @@ These environment variables influence Python's behavior.
    In addition to normal directories, individual :envvar:`PYTHONPATH` entries
    may refer to zipfiles containing pure Python modules (in either source or
    compiled form). Extension modules cannot be imported from zipfiles.
-   
+
    The default search path is installation dependent, but generally begins with
-   :file:`{prefix}/lib/python{version}`` (see :envvar:`PYTHONHOME` above).  It
+   :file:`{prefix}/lib/python{version}` (see :envvar:`PYTHONHOME` above).  It
    is *always* appended to :envvar:`PYTHONPATH`.
-   
+
    An additional directory will be inserted in the search path in front of
    :envvar:`PYTHONPATH` as described above under
    :ref:`using-on-interface-options`. The search path can be manipulated from
@@ -414,7 +414,7 @@ These environment variables influence Python's behavior.
 
 
 .. envvar:: PYTHONSTARTUP
-   
+
    If this is the name of a readable file, the Python commands in that file are
    executed before the first prompt is displayed in interactive mode.  The file
    is executed in the same namespace where interactive commands are executed so
@@ -424,7 +424,7 @@ These environment variables influence Python's behavior.
 
 
 .. envvar:: PYTHONY2K
-   
+
    Set this to a non-empty string to cause the :mod:`time` module to require
    dates specified as strings to include 4-digit years, otherwise 2-digit years
    are converted based on rules described in the :mod:`time` module
@@ -432,21 +432,21 @@ These environment variables influence Python's behavior.
 
 
 .. envvar:: PYTHONOPTIMIZE
-   
+
    If this is set to a non-empty string it is equivalent to specifying the
    :option:`-O` option.  If set to an integer, it is equivalent to specifying
    :option:`-O` multiple times.
 
 
 .. envvar:: PYTHONDEBUG
-   
+
    If this is set to a non-empty string it is equivalent to specifying the
    :option:`-d` option.  If set to an integer, it is equivalent to specifying
    :option:`-d` multiple times.
 
 
 .. envvar:: PYTHONINSPECT
-   
+
    If this is set to a non-empty string it is equivalent to specifying the
    :option:`-i` option.
 
@@ -455,20 +455,20 @@ These environment variables influence Python's behavior.
 
 
 .. envvar:: PYTHONUNBUFFERED
-   
+
    If this is set to a non-empty string it is equivalent to specifying the
    :option:`-u` option.
 
 
 .. envvar:: PYTHONVERBOSE
-   
+
    If this is set to a non-empty string it is equivalent to specifying the
    :option:`-v` option.  If set to an integer, it is equivalent to specifying
    :option:`-v` multiple times.
 
 
 .. envvar:: PYTHONCASEOK
-   
+
    If this is set, Python ignores case in :keyword:`import` statements.  This
    only works on Windows.
 
index 2ab5ee1494afead7c1a97c7b5c6942eb7d851d02..3d562a8b09f86825c04e256a228c5841518e98b0 100644 (file)
@@ -19,7 +19,7 @@ Python comes preinstalled on most Linux distributions, and is available as a
 package on all others.  However there are certain features you might want to use
 that are not available on your distro's package.  You can easily compile the
 latest version of Python from source.
-       
+
 In the event that Python doesn't come preinstalled and isn't in the repositories as
 well, you can easily make packages for your own distro.  Have a look at the
 following links:
@@ -45,8 +45,8 @@ On FreeBSD and OpenBSD
 
 * OpenBSD users use::
 
-     pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz 
-       
+     pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz
+
   For example i386 users get the 2.5.1 version of Python using::
 
      pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
@@ -87,7 +87,7 @@ source tree.
 
 Python-related paths and files
 ==============================
+
 These are subject to difference depending on local installation conventions;
 :envvar:`prefix` (``${prefix}``) and :envvar:`exec_prefix` (``${exec_prefix}``)
 are installation-dependent and should be interpreted as for GNU software; they
@@ -112,7 +112,7 @@ For example, on most Linux systems, the default for both is :file:`/usr`.
 |                                               | by the user module; not used by default  |
 |                                               | or by most applications.                 |
 +-----------------------------------------------+------------------------------------------+
+
 
 Miscellaneous
 =============
index 393ac27a8c31e11e519342e0f645feae8aaddd14..5aa91b112d52f8d2a989666365a6814955f9352b 100644 (file)
@@ -88,9 +88,9 @@ Excursus: Setting environment variables
 ---------------------------------------
 
 Windows has a built-in dialog for changing environment variables (following
-guide applies to XP classical view): Right-click the icon for your machine 
-(usually located on your Desktop and called "My Computer") and choose 
-:menuselection:`Properties` there.  Then, open the :guilabel:`Advanced` tab 
+guide applies to XP classical view): Right-click the icon for your machine
+(usually located on your Desktop and called "My Computer") and choose
+:menuselection:`Properties` there.  Then, open the :guilabel:`Advanced` tab
 and click the :guilabel:`Environment Variables` button.
 
 In short, your path is:
@@ -193,11 +193,11 @@ administrative rights):
 
 #. Launch a command prompt.
 #. Associate the correct file group with ``.py`` scripts::
-   
+
       assoc .py=Python.File
 
 #. Redirect all Python files to the new executable::
-   
+
       ftype Python.File=C:\Path\to\pythonw.exe "%1" %*
 
 
index 9ea5dc1d75fd41a953c91a3d040724872c59eb57..f5326d75928d168c17de74ff6ed40cb7be56787b 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  What's New in Python 2.0  
+  What's New in Python 2.0
 ****************************
 
 :Author: A.M. Kuchling and Moshe Zadka
@@ -277,11 +277,11 @@ additional information.  Take the first example in the previous paragraph,
 finding all the strings in the list containing a given substring.  You could
 write the following to do it::
 
-   # Given the list L, make a list of all strings 
+   # Given the list L, make a list of all strings
    # containing the substring S.
-   sublist = filter( lambda s, substring=S: 
+   sublist = filter( lambda s, substring=S:
                         string.find(s, substring) != -1,
-                 L)
+                     L)
 
 Because of Python's scoping rules, a default argument is used so that the
 anonymous function created by the :keyword:`lambda` statement knows what
@@ -291,9 +291,9 @@ substring is being searched for.  List comprehensions make this cleaner::
 
 List comprehensions have the form::
 
-   [ expression for expr in sequence1 
+   [ expression for expr in sequence1
                 for expr2 in sequence2 ...
-            for exprN in sequenceN
+                for exprN in sequenceN
                 if condition ]
 
 The :keyword:`for`...\ :keyword:`in` clauses contain the sequences to be
@@ -312,8 +312,8 @@ following Python code::
        ...
            for exprN in sequenceN:
                 if (condition):
-                     # Append the value of 
-                     # the expression to the 
+                     # Append the value of
+                     # the expression to the
                      # resulting list.
 
 This means that when there are multiple :keyword:`for`...\ :keyword:`in`
@@ -368,7 +368,7 @@ instance with an incremented value.
        def __init__(self, value):
            self.value = value
        def __iadd__(self, increment):
-       return Number( self.value + increment)
+           return Number( self.value + increment)
 
    n = Number(5)
    n += 3
@@ -590,7 +590,7 @@ raised should still work. ::
 
    def f():
        print "i=",i
-       i = i + 1 
+       i = i + 1
    f()
 
 Two new exceptions, :exc:`TabError` and :exc:`IndentationError`, have been
@@ -627,7 +627,7 @@ would do, and also inserts it into the dictionary as the value for *key*.  Thus,
 the following lines of code::
 
    if dict.has_key( key ): return dict[key]
-   else: 
+   else:
        dict[key] = []
        return dict[key]
 
@@ -836,14 +836,14 @@ the simple case, when the software contains only .py files, a minimal
 :file:`setup.py` can be just a few lines long::
 
    from distutils.core import setup
-   setup (name = "foo", version = "1.0", 
+   setup (name = "foo", version = "1.0",
           py_modules = ["module1", "module2"])
 
 The :file:`setup.py` file isn't much more complicated if the software consists
 of a few packages::
 
    from distutils.core import setup
-   setup (name = "foo", version = "1.0", 
+   setup (name = "foo", version = "1.0",
           packages = ["package", "package.subpackage"])
 
 A C extension can be the most complicated case; here's an example taken from
@@ -852,15 +852,14 @@ the PyXML package::
    from distutils.core import setup, Extension
 
    expat_extension = Extension('xml.parsers.pyexpat',
-       define_macros = [('XML_NS', None)],
-       include_dirs = [ 'extensions/expat/xmltok',
-                        'extensions/expat/xmlparse' ],
-       sources = [ 'extensions/pyexpat.c',
-                   'extensions/expat/xmltok/xmltok.c',
-                   'extensions/expat/xmltok/xmlrole.c',
-                     ]
+        define_macros = [('XML_NS', None)],
+        include_dirs = [ 'extensions/expat/xmltok',
+                         'extensions/expat/xmlparse' ],
+        sources = [ 'extensions/pyexpat.c',
+                    'extensions/expat/xmltok/xmltok.c',
+                    'extensions/expat/xmltok/xmlrole.c', ]
           )
-   setup (name = "PyXML", version = "0.5.4", 
+   setup (name = "PyXML", version = "0.5.4",
           ext_modules =[ expat_extension ] )
 
 The Distutils can also take care of creating source and binary distributions.
index c3f12802292a6031b5a0b279e1e78a6485b63a3c..6b2ce3faa20be2248071a94be5146781c2889948 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  What's New in Python 2.1  
+  What's New in Python 2.1
 ****************************
 
 :Author: A.M. Kuchling
@@ -98,7 +98,7 @@ To make the preceding explanation a bit clearer, here's an example::
    x = 1
    def f():
        # The next line is a syntax error
-       exec 'x=2'  
+       exec 'x=2'
        def g():
            return x
 
index 138329830a210f6bc7883c1df78bb2b9ff3177fa..ec435f71ba37ec43db25cbea62e60983558075a3 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  What's New in Python 2.2  
+  What's New in Python 2.2
 ****************************
 
 :Author: A.M. Kuchling
@@ -295,7 +295,7 @@ will be used in methods to call a method in the superclass; for example,
 
    class D (B,C):
        def save (self):
-       # Call superclass .save()
+           # Call superclass .save()
            super(D, self).save()
            # Save D's private information here
            ...
@@ -473,7 +473,7 @@ there are no more values to be returned, calling :meth:`next` should raise the
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    StopIteration
-   >>>      
+   >>>
 
 In 2.2, Python's :keyword:`for` statement no longer expects a sequence; it
 expects something for which :func:`iter` will return an iterator. For backward
@@ -909,7 +909,7 @@ To make the preceding explanation a bit clearer, here's an example::
    x = 1
    def f():
        # The next line is a syntax error
-       exec 'x=2'  
+       exec 'x=2'
        def g():
            return x
 
@@ -952,8 +952,8 @@ New and Improved Modules
      items = s.meerkat.getItems( {'channel': 4} )
 
      # 'items' is another list of dictionaries, like this:
-     # [{'link': 'http://freshmeat.net/releases/52719/', 
-     #   'description': 'A utility which converts HTML to XSL FO.', 
+     # [{'link': 'http://freshmeat.net/releases/52719/',
+     #   'description': 'A utility which converts HTML to XSL FO.',
      #   'title': 'html2fo 0.3 (Default)'}, ... ]
 
   The :mod:`SimpleXMLRPCServer` module makes it easy to create straightforward
index da4f24fa8b5b3e30c747ac989f246c15093d352d..eeb471afe1b38270676e0b24f9487675e53315e9 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  What's New in Python 2.3  
+  What's New in Python 2.3
 ****************************
 
 :Author: A.M. Kuchling
@@ -301,7 +301,7 @@ For example::
     --------                   -------
         8467                   1 file
    amk@nyman:~/src/python$ ./python
-   Python 2.3 (#1, Aug 1 2003, 19:54:32) 
+   Python 2.3 (#1, Aug 1 2003, 19:54:32)
    >>> import sys
    >>> sys.path.insert(0, '/tmp/example.zip')  # Add .zip file to front of path
    >>> import jwzthreading
@@ -671,7 +671,7 @@ with older versions of the Distutils::
          # ...
          }
 
-   if (hasattr(core, 'setup_keywords') and 
+   if (hasattr(core, 'setup_keywords') and
        'classifiers' in core.setup_keywords):
        kw['classifiers'] = \
            ['Topic :: Internet :: WWW/HTTP :: Dynamic Content',
@@ -1027,7 +1027,7 @@ Here are all of the changes that Python 2.3 makes to the core Python language.
   creating small dictionaries::
 
      >>> dict(red=1, blue=2, green=3, black=4)
-     {'blue': 2, 'black': 4, 'green': 3, 'red': 1}    
+     {'blue': 2, 'black': 4, 'green': 3, 'red': 1}
 
   (Contributed by Just van Rossum.)
 
@@ -1622,7 +1622,7 @@ complete list of changes, or look through the CVS logs for all the details.
      ...         self.valuelist.pop(i)
      ...     def keys(self):
      ...         return list(self.keylist)
-     ... 
+     ...
      >>> s = SeqDict()
      >>> dir(s)      # See that other dictionary methods are implemented
      ['__cmp__', '__contains__', '__delitem__', '__doc__', '__getitem__',
@@ -1779,7 +1779,7 @@ The help message is automatically generated for you::
                            set input filename
      -lLENGTH, --length=LENGTH
                            set maximum length of output
-   $ 
+   $
 
 See the module's documentation for more details.
 
index 59788baba44e458a2993b7832b32e9ce28368aa4..9e438ac7615037d282262b2d366ffb1a65146078 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  What's New in Python 2.4  
+  What's New in Python 2.4
 ****************************
 
 :Author: A.M. Kuchling
@@ -63,10 +63,10 @@ symmetric differences. ::
    >>> a.add('z')                          # add a new element
    >>> a.update('wxy')                     # add multiple new elements
    >>> a
-   set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'x', 'z'])       
+   set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'x', 'z'])
    >>> a.remove('x')                       # take one element out
    >>> a
-   set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'z'])       
+   set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'z'])
 
 The :func:`frozenset` type is an immutable version of :func:`set`. Since it is
 immutable and hashable, it may be used as a dictionary key or as a member of
@@ -351,7 +351,7 @@ iterator that loops over the elements of the sequence  in reverse order.   ::
 
    >>> for i in reversed(xrange(1,4)):
    ...    print i
-   ... 
+   ...
    3
    2
    1
@@ -366,7 +366,7 @@ you want to reverse an iterator, first convert it to  a list with :func:`list`.
    >>> input = open('/etc/passwd', 'r')
    >>> for line in reversed(list(input)):
    ...   print line
-   ... 
+   ...
    root:*:0:0:System Administrator:/var/root:/bin/tcsh
      ...
 
@@ -396,10 +396,10 @@ single class called :class:`Popen`  whose constructor supports a number of
 different keyword arguments. ::
 
    class Popen(args, bufsize=0, executable=None,
-           stdin=None, stdout=None, stderr=None,
-           preexec_fn=None, close_fds=False, shell=False,
-           cwd=None, env=None, universal_newlines=False,
-           startupinfo=None, creationflags=0):
+               stdin=None, stdout=None, stderr=None,
+               preexec_fn=None, close_fds=False, shell=False,
+               cwd=None, env=None, universal_newlines=False,
+               startupinfo=None, creationflags=0):
 
 *args* is commonly a sequence of strings that will be the arguments to the
 program executed as the subprocess.  (If the *shell* argument is true, *args*
@@ -650,7 +650,7 @@ the precision of the default context::
    28
    >>> decimal.Decimal(1) / decimal.Decimal(7)
    Decimal("0.1428571428571428571428571429")
-   >>> decimal.getcontext().prec = 9 
+   >>> decimal.getcontext().prec = 9
    >>> decimal.Decimal(1) / decimal.Decimal(7)
    Decimal("0.142857143")
 
@@ -665,7 +665,7 @@ raised::
    >>> decimal.getcontext().traps[decimal.DivisionByZero] = False
    >>> decimal.Decimal(1) / decimal.Decimal(0)
    Decimal("Infinity")
-   >>> 
+   >>>
 
 The :class:`Context` instance also has various methods for formatting  numbers
 such as :meth:`to_eng_string` and :meth:`to_sci_string`.
@@ -803,7 +803,7 @@ Here are all of the changes that Python 2.4 makes to the core Python language.
      >>> 'www.python.org'.split('.', 1)
      ['www', 'python.org']
      'www.python.org'.rsplit('.', 1)
-     ['www.python', 'org']        
+     ['www.python', 'org']
 
 * Three keyword parameters, *cmp*, *key*, and *reverse*, were added to the
   :meth:`sort` method of lists. These parameters make some common usages of
@@ -1045,7 +1045,7 @@ complete list of changes, or look through the CVS logs for all the details.
      >>> list(d)                 # list the contents of the deque
      ['g', 'h', 'i']
      >>> 'h' in d                # search the deque
-     True  
+     True
 
   Several modules, such as the :mod:`Queue` and :mod:`threading` modules, now take
   advantage of :class:`collections.deque` for improved performance.  (Contributed
@@ -1106,13 +1106,13 @@ complete list of changes, or look through the CVS logs for all the details.
      >>> L = [2, 4, 6, 7, 8, 9, 11, 12, 14]
      >>> for key_val, it in itertools.groupby(L, lambda x: x % 2):
      ...    print key_val, list(it)
-     ... 
+     ...
      0 [2, 4, 6]
      1 [7]
      0 [8]
      1 [9, 11]
      0 [12, 14]
-     >>> 
+     >>>
 
   :func:`groupby` is typically used with sorted input.  The logic for
   :func:`groupby` is similar to the Unix ``uniq`` filter which makes it handy for
@@ -1120,21 +1120,21 @@ complete list of changes, or look through the CVS logs for all the details.
 
      >>> word = 'abracadabra'
      >>> letters = sorted(word)   # Turn string into a sorted list of letters
-     >>> letters 
+     >>> letters
      ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'd', 'r', 'r']
      >>> for k, g in itertools.groupby(letters):
      ...    print k, list(g)
-     ... 
+     ...
      a ['a', 'a', 'a', 'a', 'a']
      b ['b', 'b']
      c ['c']
      d ['d']
      r ['r', 'r']
      >>> # List unique letters
-     >>> [k for k, g in groupby(letters)]                     
+     >>> [k for k, g in groupby(letters)]
      ['a', 'b', 'c', 'd', 'r']
      >>> # Count letter occurrences
-     >>> [(k, len(list(g))) for k, g in groupby(letters)]     
+     >>> [(k, len(list(g))) for k, g in groupby(letters)]
      [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)]
 
   (Contributed by Hye-Shik Chang.)
@@ -1175,7 +1175,7 @@ complete list of changes, or look through the CVS logs for all the details.
      import logging
      logging.basicConfig(filename='/var/log/application.log',
          level=0,  # Log all messages
-         format='%(levelname):%(process):%(thread):%(message)')                    
+         format='%(levelname):%(process):%(thread):%(message)')
 
   Other additions to the :mod:`logging` package include a :meth:`log(level, msg)`
   convenience method, as well as a :class:`TimedRotatingFileHandler` class that
@@ -1428,7 +1428,7 @@ Running the above function's tests with :const:`doctest.REPORT_UDIFF` specified,
 you get the following output::
 
    **********************************************************************
-   File ``t.py'', line 15, in g
+   File "t.py", line 15, in g
    Failed example:
        g(4)
    Differences (unified diff with -expected +actual):
index 43ba6e5a6351fbdbedda486acd128d8f6cfca2b5..e1e2887614a4408ec516dfde2483fa604bd1f4a9 100644 (file)
@@ -1,5 +1,5 @@
 ****************************
-  What's New in Python 2.5  
+  What's New in Python 2.5
 ****************************
 
 :Author: A.M. Kuchling
@@ -220,7 +220,7 @@ in the package index, determine the dependencies for a package, and download the
 required packages. ::
 
    VERSION = '1.0'
-   setup(name='PyPackage', 
+   setup(name='PyPackage',
          version=VERSION,
          requires=['numarray', 'zlib (>=1.1.4)'],
          obsoletes=['OldPackage']
@@ -388,7 +388,7 @@ write::
    else:
        else-block
    finally:
-       final-block 
+       final-block
 
 The code in *block-1* is executed.  If the code raises an exception, the various
 :keyword:`except` blocks are tested: if the exception is of class
@@ -485,7 +485,7 @@ And here's an example of changing the counter::
    9
    >>> print it.next()
    Traceback (most recent call last):
-     File ``t.py'', line 15, in ?
+     File "t.py", line 15, in ?
        print it.next()
    StopIteration
 
@@ -835,8 +835,8 @@ catch all exceptions, so you commonly need to list :exc:`KeyboardInterrupt` and
        ...
    except (KeyboardInterrupt, SystemExit):
        raise
-   except: 
-       # Log error...  
+   except:
+       # Log error...
        # Continue running program...
 
 In Python 2.5, you can now write ``except Exception`` to achieve the same
@@ -947,7 +947,7 @@ arguments and returns an integer giving the slice index to use.  For example::
 
    class C:
        def __index__ (self):
-           return self.value  
+           return self.value
 
 The return value must be either a Python integer or long integer. The
 interpreter will check that the type returned is correct, and raises a
@@ -1035,9 +1035,9 @@ Here are all of the changes that Python 2.5 makes to the core Python language.
 
      L = ['medium', 'longest', 'short']
      # Prints 'longest'
-     print max(L, key=len)              
+     print max(L, key=len)
      # Prints 'short', because lexicographically 'short' has the largest value
-     print max(L)         
+     print max(L)
 
   (Contributed by Steven Bethard and Raymond Hettinger.)
 
@@ -1070,8 +1070,8 @@ Here are all of the changes that Python 2.5 makes to the core Python language.
   using the default ASCII encoding.   The result of the comparison is false::
 
      >>> chr(128) == unichr(128)   # Can't convert chr(128) to Unicode
-     __main__:1: UnicodeWarning: Unicode equal comparison failed 
-       to convert both arguments to Unicode - interpreting them 
+     __main__:1: UnicodeWarning: Unicode equal comparison failed
+       to convert both arguments to Unicode - interpreting them
        as being unequal
      False
      >>> chr(127) == unichr(127)   # chr(127) can be converted
@@ -1259,10 +1259,10 @@ complete list of changes, or look through the SVN logs for all the details.
 
   Printing ``index`` results in the following output::
 
-     defaultdict(<type 'list'>, {'c': ['cammin', 'che'], 'e': ['era'], 
-             'd': ['del', 'di', 'diritta'], 'm': ['mezzo', 'mi'], 
-             'l': ['la'], 'o': ['oscura'], 'n': ['nel', 'nostra'], 
-             'p': ['per'], 's': ['selva', 'smarrita'], 
+     defaultdict(<type 'list'>, {'c': ['cammin', 'che'], 'e': ['era'],
+             'd': ['del', 'di', 'diritta'], 'm': ['mezzo', 'mi'],
+             'l': ['la'], 'o': ['oscura'], 'n': ['nel', 'nostra'],
+             'p': ['per'], 's': ['selva', 'smarrita'],
              'r': ['ritrovai'], 'u': ['una'], 'v': ['vita', 'via']}
 
   (Contributed by Guido van Rossum.)
@@ -1884,17 +1884,17 @@ is that the constructor functions for creating new hashing objects are named
 differently. ::
 
    # Old versions
-   h = md5.md5()   
-   h = md5.new()   
+   h = md5.md5()
+   h = md5.new()
 
-   # New version 
+   # New version
    h = hashlib.md5()
 
    # Old versions
-   h = sha.sha()   
-   h = sha.new()   
+   h = sha.sha()
+   h = sha.new()
 
-   # New version 
+   # New version
    h = hashlib.sha1()
 
    # Hash that weren't previously available
@@ -2191,7 +2191,7 @@ Changes to Python's build process and to the C API include:
   case that your extensions were using it, you can replace it by something like
   the following::
 
-     range = PyObject_CallFunction((PyObject*) &PyRange_Type, "lll", 
+     range = PyObject_CallFunction((PyObject*) &PyRange_Type, "lll",
                                    start, stop, step);
 
 .. ======================================================================
index 6d0d4224d913e2224adac9c7be0e23ba7a58e36d..457bef2b09e6be2d2a187204907e886ac14d2cc4 100644 (file)
@@ -586,30 +586,30 @@ multiple of 4.
 
 
     def factorial(queue, N):
-       "Compute a factorial."
-       # If N is a multiple of 4, this function will take much longer.
-       if (N % 4) == 0:
-           time.sleep(.05 * N/4)
+        "Compute a factorial."
+        # If N is a multiple of 4, this function will take much longer.
+        if (N % 4) == 0:
+            time.sleep(.05 * N/4)
 
-       # Calculate the result
-       fact = 1L
-       for i in range(1, N+1):
-           fact = fact * i
+        # Calculate the result
+        fact = 1L
+        for i in range(1, N+1):
+            fact = fact * i
 
-       # Put the result on the queue
-       queue.put(fact)
+        # Put the result on the queue
+        queue.put(fact)
 
     if __name__ == '__main__':
-       queue = Queue()
+        queue = Queue()
 
-       N = 5
+        N = 5
 
-       p = Process(target=factorial, args=(queue, N))
-       p.start()
-       p.join()
+        p = Process(target=factorial, args=(queue, N))
+        p.start()
+        p.join()
 
-       result = queue.get()
-       print 'Factorial', N, '=', result
+        result = queue.get()
+        print 'Factorial', N, '=', result
 
 A :class:`Queue` is used to communicate the input parameter *N* and
 the result.  The :class:`Queue` object is stored in a global variable.
@@ -630,12 +630,12 @@ across 5 worker processes and retrieve a list of results::
     from multiprocessing import Pool
 
     def factorial(N, dictionary):
-       "Compute a factorial."
-       ...
+        "Compute a factorial."
+        ...
     p = Pool(5)
     result = p.map(factorial, range(1, 1000, 10))
     for v in result:
-       print v
+        print v
 
 This produces the following output::
 
@@ -744,7 +744,7 @@ supply compound field names that read attributes or access dictionary keys::
     >>> import sys
     >>> print 'Platform: {0.platform}\nPython version: {0.version}'.format(sys)
     Platform: darwin
-    Python version: 2.6a1+ (trunk:61261M, Mar  5 2008, 20:29:41) 
+    Python version: 2.6a1+ (trunk:61261M, Mar  5 2008, 20:29:41)
     [GCC 4.0.1 (Apple Computer, Inc. build 5367)]'
 
     >>> import mimetypes
@@ -958,8 +958,8 @@ representing ``ABC``; in 2.6, ``bytes([65, 66, 67])`` returns the
 The primary use of :class:`bytes` in 2.6 will be to write tests of
 object type such as ``isinstance(x, bytes)``.  This will help the 2to3
 converter, which can't tell whether 2.x code intends strings to
-contain either characters or 8-bit bytes; you can now 
-use either :class:`bytes` or :class:`str` to represent your intention 
+contain either characters or 8-bit bytes; you can now
+use either :class:`bytes` or :class:`str` to represent your intention
 exactly, and the resulting code will also be correct in Python 3.0.
 
 There's also a ``__future__`` import that causes all string literals
@@ -1834,9 +1834,9 @@ changes, or look through the Subversion logs for all the details.
   "/cgi-bin/add.py?category=1".  (Contributed by Alexandre Fiori and
   Nubis; :issue:`1817`.)
 
-  The :func:`parse_qs` and :func:`parse_qsl` functions have been 
+  The :func:`parse_qs` and :func:`parse_qsl` functions have been
   relocated from the :mod:`cgi` module to the :mod:`urlparse` module.
-  The versions still available in the :mod:`cgi` module will 
+  The versions still available in the :mod:`cgi` module will
   trigger :exc:`PendingDeprecationWarning` messages in 2.6
   (:issue:`600362`).
 
@@ -1885,9 +1885,9 @@ changes, or look through the Subversion logs for all the details.
      ('id', 'name', 'type', 'size')
 
      >>> var = var_type(1, 'frequency', 'int', 4)
-     >>> print var[0], var.id          # Equivalent
+     >>> print var[0], var.id    # Equivalent
      1 1
-     >>> print var[2], var.type          # Equivalent
+     >>> print var[2], var.type  # Equivalent
      int int
      >>> var._asdict()
      {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'}
@@ -1931,7 +1931,7 @@ changes, or look through the Subversion logs for all the details.
 * A new window method in the :mod:`curses` module,
   :meth:`chgat`, changes the display attributes for a certain number of
   characters on a single line.  (Contributed by Fabian Kreutz.)
-  
+
   ::
 
      # Boldface text starting at y=0,x=21
@@ -2046,8 +2046,8 @@ changes, or look through the Subversion logs for all the details.
 
      >>> list(itertools.product([1,2,3], [4,5,6]))
      [(1, 4), (1, 5), (1, 6),
-         (2, 4), (2, 5), (2, 6),
-         (3, 4), (3, 5), (3, 6)]
+      (2, 4), (2, 5), (2, 6),
+      (3, 4), (3, 5), (3, 6)]
 
   The optional *repeat* keyword argument is used for taking the
   product of an iterable or a set of iterables with themselves,
@@ -2428,9 +2428,9 @@ changes, or look through the Subversion logs for all the details.
   :issue:`742598`, :issue:`1193577`.)
 
 * The :mod:`sqlite3` module, maintained by Gerhard Haering,
-  has been updated from version 2.3.2 in Python 2.5 to 
+  has been updated from version 2.3.2 in Python 2.5 to
   version 2.4.1.
+
 * The :mod:`struct` module now supports the C99 :ctype:`_Bool` type,
   using the format character ``'?'``.
   (Contributed by David Remahl.)
@@ -2525,9 +2525,9 @@ changes, or look through the Subversion logs for all the details.
   ``with tempfile.NamedTemporaryFile() as tmp: ...``.
   (Contributed by Alexander Belopolsky; :issue:`2021`.)
 
-* The :mod:`test.test_support` module gained a number 
-  of context managers useful for writing tests. 
-  :func:`EnvironmentVarGuard` is a 
+* The :mod:`test.test_support` module gained a number
+  of context managers useful for writing tests.
+  :func:`EnvironmentVarGuard` is a
   context manager that temporarily changes environment variables and
   automatically restores them to their old values.
 
@@ -2542,7 +2542,7 @@ changes, or look through the Subversion logs for all the details.
           f = urllib.urlopen('https://sf.net')
           ...
 
-  Finally, :func:`check_warnings` resets the :mod:`warning` module's 
+  Finally, :func:`check_warnings` resets the :mod:`warning` module's
   warning filters and returns an object that will record all warning
   messages triggered (:issue:`3781`)::
 
@@ -2582,7 +2582,7 @@ changes, or look through the Subversion logs for all the details.
   :meth:`activeCount` method is renamed to :meth:`active_count`.  Both
   the 2.6 and 3.0 versions of the module support the same properties
   and renamed methods, but don't remove the old methods.  No date has been set
-  for the deprecation of the old APIs in Python 3.x; the old APIs won't 
+  for the deprecation of the old APIs in Python 3.x; the old APIs won't
   be removed in any 2.x version.
   (Carried out by several people, most notably Benjamin Peterson.)
 
@@ -2639,7 +2639,7 @@ changes, or look through the Subversion logs for all the details.
   (Added by Facundo Batista.)
 
 * The Unicode database provided by the :mod:`unicodedata` module
-  has been updated to version 5.1.0.  (Updated by 
+  has been updated to version 5.1.0.  (Updated by
   Martin von Loewis; :issue:`3811`.)
 
 * The :mod:`warnings` module's :func:`formatwarning` and :func:`showwarning`
@@ -2650,7 +2650,7 @@ changes, or look through the Subversion logs for all the details.
   A new function, :func:`catch_warnings`, is a context manager
   intended for testing purposes that lets you temporarily modify the
   warning filters and then restore their original values (:issue:`3781`).
-  
+
 * The XML-RPC :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
   classes can now be prevented from immediately opening and binding to
   their socket by passing True as the ``bind_and_activate``
@@ -3220,8 +3220,8 @@ that may require changes to your code:
 
 * :meth:`object.__init__` previously accepted arbitrary arguments and
   keyword arguments, ignoring them.  In Python 2.6, this is no longer
-  allowed and will result in a :exc:`TypeError`.  This will affect 
-  :meth:`__init__` methods that end up calling the corresponding 
+  allowed and will result in a :exc:`TypeError`.  This will affect
+  :meth:`__init__` methods that end up calling the corresponding
   method on :class:`object` (perhaps through using :func:`super`).
   See :issue:`1683368` for discussion.
 
@@ -3281,7 +3281,7 @@ Acknowledgements
 
 The author would like to thank the following people for offering
 suggestions, corrections and assistance with various drafts of this
-article: Georg Brandl, Steve Brown, Nick Coghlan, Ralph Corderoy, 
-Jim Jewett, Kent Johnson, Chris Lambacher,  Martin Michlmayr, 
+article: Georg Brandl, Steve Brown, Nick Coghlan, Ralph Corderoy,
+Jim Jewett, Kent Johnson, Chris Lambacher,  Martin Michlmayr,
 Antoine Pitrou, Brian Warner.
 
diff --git a/LICENSE b/LICENSE
index 69acaeb7531b670104a61bb4e0371ca516d581f1..0f72a618c4093730e015e44be5e895cc22cc479a 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -88,15 +88,14 @@ PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
 otherwise using this software ("Python") in source or binary form and
 its associated documentation.
 
-2. Subject to the terms and conditions of this License Agreement, PSF
-hereby grants Licensee a nonexclusive, royalty-free, world-wide
-license to reproduce, analyze, test, perform and/or display publicly,
-prepare derivative works, distribute, and otherwise use Python
-alone or in any derivative version, provided, however, that PSF's
-License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Python Software Foundation; 
-All Rights Reserved" are retained in Python alone or in any derivative 
-version prepared by Licensee.
+2. Subject to the terms and conditions of this License Agreement, PSF hereby
+grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
+analyze, test, perform and/or display publicly, prepare derivative works,
+distribute, and otherwise use Python alone or in any derivative version,
+provided, however, that PSF's License Agreement and PSF's notice of copyright,
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Python
+Software Foundation; All Rights Reserved" are retained in Python alone or in any
+derivative version prepared by Licensee.
 
 3. In the event Licensee prepares a derivative work that is based on
 or incorporates Python or any part thereof, and wants to make
index 4c64839ed2c8de3e47b3d97141e322cd1d29e2b5..bd097bd83666a75193538a2a07e9ae237b9cef8c 100644 (file)
@@ -573,7 +573,7 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
         del d
 
 def _process_Nav_args(dftflags, **args):
-    import aepack
+    import Carbon.AppleEvents
     import Carbon.AE
     import Carbon.File
     for k in args.keys():
@@ -585,11 +585,14 @@ def _process_Nav_args(dftflags, **args):
     if args.has_key('defaultLocation') and \
             not isinstance(args['defaultLocation'], Carbon.AE.AEDesc):
         defaultLocation = args['defaultLocation']
-        if isinstance(defaultLocation, (Carbon.File.FSSpec, Carbon.File.FSRef)):
-            args['defaultLocation'] = aepack.pack(defaultLocation)
+        if isinstance(defaultLocation, Carbon.File.FSSpec):
+            args['defaultLocation'] = Carbon.AE.AECreateDesc(
+                    Carbon.AppleEvents.typeFSS, defaultLocation.data)
         else:
-            defaultLocation = Carbon.File.FSRef(defaultLocation)
-            args['defaultLocation'] = aepack.pack(defaultLocation)
+            if not isinstance(defaultLocation, Carbon.File.FSRef):
+                defaultLocation = Carbon.File.FSRef(defaultLocation)
+            args['defaultLocation'] = Carbon.AE.AECreateDesc(
+                    Carbon.AppleEvents.typeFSRef, defaultLocation.data)
     if args.has_key('typeList') and not isinstance(args['typeList'], Carbon.Res.ResourceType):
         typeList = args['typeList'][:]
         # Workaround for OSX typeless files:
index d7724fa271b58d2a3cd897d67895142e77bbe407..337cc7f1f1d46c5d5693d160de2d5b358e7a8085 100644 (file)
@@ -62,7 +62,14 @@ def mkdirs(dst):
     if os.sep == ':' and not ':' in head:
         head = head + ':'
     mkdirs(head)
-    os.mkdir(dst, 0777)
+
+    try:
+        os.mkdir(dst, 0777)
+    except OSError, e:
+        # be happy if someone already created the path
+        if e.errno != errno.EEXIST:
+            raise
+
 
 def touched(dst):
     """Tell the finder a file has changed. No-op on MacOSX."""
index fbb37e12e752f3402aa8d1d98783c13c58b74eb3..4fe993ebf251d852febe3866e81dd536a2583437 100644 (file)
@@ -18,7 +18,7 @@ from Carbon import Qdoffs
 from Carbon import QDOffscreen
 from Carbon import Res
 try:
-    import MediaDescr
+    from Carbon import MediaDescr
 except ImportError:
     def _audiodescr(data):
         return None
index 4e2de3d005883032b18b3c85da5a17a731112728..02dadef4fbd46e48085fe4f89c00daf757281600 100644 (file)
@@ -420,7 +420,7 @@ class TestBasic(unittest.TestCase):
             gc.collect()
 
     def test_container_iterator(self):
-        # Bug # XXX: tp_traverse was not implemented for deque iterator objects
+        # Bug #3680: tp_traverse was not implemented for deque iterator objects
         class C(object):
             pass
         for i in range(2):
index 14d62f5024b7c209fe5eb1b9128c75ba4fcd04f7..0907744ab5f024b0c16acbd3c9f8e5da3b2f9469 100644 (file)
@@ -556,7 +556,7 @@ class DictTest(unittest.TestCase):
         d = {}
 
     def test_container_iterator(self):
-        # Bug # XXX: tp_traverse was not implemented for dictiter objects
+        # Bug #3680: tp_traverse was not implemented for dictiter objects
         class C(object):
             pass
         iterators = (dict.iteritems, dict.itervalues, dict.iterkeys)
index 8d0571236511e365e83cacbe8e08c0b6e1ef0746..886c4b8db36b9c1663b58dff712cf13a9b8febea 100644 (file)
@@ -324,7 +324,7 @@ class TestJointOps(unittest.TestCase):
         self.assertEqual(d3, dict.fromkeys(d, 123))
 
     def test_container_iterator(self):
-        # Bug # XXX: tp_traverse was not implemented for set iterator object
+        # Bug #3680: tp_traverse was not implemented for set iterator object
         class C(object):
             pass
         obj = C()
index 569bec29dbc7604f6c44067c159c48cf4e59f343..8c37051d4591bac45173e01f414b7d07deb454f6 100644 (file)
@@ -773,8 +773,8 @@ altbininstall:      $(BUILDPYTHON)
        done
        $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
        if test -f $(LDLIBRARY); then \
-               if test "$(SO)" = .dll; then \
-                       $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(BINDIR); \
+               if test -n "$(DLLLIBRARY)" ; then \
+                       $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
                else \
                        $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
                        if test $(LDLIBRARY) != $(INSTSONAME); then \
@@ -909,7 +909,7 @@ $(srcdir)/Lib/$(PLATDIR):
        export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
        export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
        export EXE; EXE="$(BUILDEXE)"; \
-       cd $(srcdir)/Lib/$(PLATDIR); ./regen
+       cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
 
 # Install the include files
 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
index 0f0067c6020505d614cbb2fb77f85343c366fe2b..cd5f2e36ad404772b7fedd8cb587231b024bca17 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,11 @@ What's New in Python 2.6.2
 Core and Builtins
 -----------------
 
+- Issue #4075: Use OutputDebugStringW in Py_FatalError.
+
+- Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
+  file with `str' filename on Windows.
+
 - Issue #3680: Reference cycles created through a dict, set or deque iterator
   did not get collected.
 
@@ -233,6 +238,14 @@ Library
 - Issue #4730: Fixed the cPickle module to handle correctly astral characters
   when protocol 0 is used.
 
+- Issue #16278952: plat-mac/videoreader.py now correctly imports MediaDescr
+
+- Issue #1737832 : plat-mac/EasyDialog.py no longer uses the broken aepack
+  module.
+
+- Issue #1149804: macostools.mkdirs now even works when another process
+  creates one of the needed subdirectories.
+
 Tools/Demos
 -----------
 
@@ -241,6 +254,8 @@ Tools/Demos
 Build
 -----
 
+- Issue #4472: "configure --enable-shared" now works on OSX
+
 - Issues #4728 and #4060: WORDS_BIGEDIAN is now correct in Universal builds.
 
 - Issue #4389: Add icon to the uninstall entry in "add-and-remove-programs".
@@ -273,6 +288,8 @@ C-API
 Extension Modules
 -----------------
 
+- Issue #4051: Prevent conflict of UNICODE macros in cPickle.
+
 - Issue #4228: Pack negative values the same way as 2.4 in struct's L format.
 
 - Issue #1040026: Fix os.times result on systems where HZ is incorrect.
index 37633d2dda88d840c064a99f5a0b3c34a0b788dd..002953203247cf61490170f5c45e43655156b4f4 100644 (file)
@@ -967,7 +967,7 @@ deque_iter(dequeobject *deque)
        it->deque = deque;
        it->state = deque->state;
        it->counter = deque->len;
-       _PyObject_GC_TRACK(it);
+       PyObject_GC_Track(it);
        return (PyObject *)it;
 }
 
@@ -1077,7 +1077,7 @@ deque_reviter(dequeobject *deque)
        it->deque = deque;
        it->state = deque->state;
        it->counter = deque->len;
-       _PyObject_GC_TRACK(it);
+       PyObject_GC_Track(it);
        return (PyObject *)it;
 }
 
index ca12822e1db043aca5f8b9e5aa4210b6d7cfd6ea..2dc3d743b85f8279c525df2af15cebcc02d74d4e 100644 (file)
@@ -265,10 +265,11 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
                Py_END_ALLOW_THREADS
                if (self->fd < 0) {
 #ifdef MS_WINDOWS
-                       PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
-#else
-                       PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
+                       if (widename != NULL)
+                               PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
+                       else
 #endif
+                               PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
                        goto error;
                }
                if(dircheck(self, name) < 0)
index 18baee1c395f3e129519dabbe6b8000d87cf47b3..7f836c31269b3d04ecf8a8e435db2ec070d9cffd 100644 (file)
@@ -17,6 +17,14 @@ PyDoc_STRVAR(cPickle_module_documentation,
 /* Bump this when new opcodes are added to the pickle protocol. */
 #define HIGHEST_PROTOCOL 2
 
+/*
+ * Note: The UNICODE macro controls the TCHAR meaning of the win32 API. Since
+ * all headers have already been included here, we can safely redefine it.
+ */
+#ifdef UNICODE
+#  undef UNICODE
+#endif
+
 /*
  * Pickle opcodes.  These must be kept in synch with pickle.py.  Extensive
  * docs are in pickletools.py.
index bd892b695d61339c16f14f8d690c16800b5c0090..7620d58462ab337089ecb106ccc492b40e438fe8 100644 (file)
@@ -167,7 +167,7 @@ class ASDLParser(spark.GenericParser, object):
         return Product(fields)
 
     def p_sum_0(self, (constructor,)):
-        " sum ::= constructor """
+        " sum ::= constructor "
         return [constructor]
 
     def p_sum_1(self, (constructor, _, sum)):
index df70e8bdf5e41dfa191e7490ccbe885d91871cf1..8864cdbbc0a9ce0b5014b8da49e6087dbce6944a 100644 (file)
@@ -4,7 +4,7 @@
 
 static char cprt[] = 
 "\
-Copyright (c) 2001-2008 Python Software Foundation.\n\
+Copyright (c) 2001-2009 Python Software Foundation.\n\
 All Rights Reserved.\n\
 \n\
 Copyright (c) 2000 BeOpen.com.\n\
index 54f3c5784bd86b1384e07ad4214890a971111a2d..f2cd819b1c4d2de1e5300c88f43930ef48789b5d 100644 (file)
 #include <signal.h>
 #endif
 
+#ifdef MS_WINDOWS
+#include "malloc.h" /* for alloca */
+#endif
+
 #ifdef HAVE_LANGINFO_H
 #include <locale.h>
 #include <langinfo.h>
@@ -1628,9 +1632,21 @@ Py_FatalError(const char *msg)
 {
        fprintf(stderr, "Fatal Python error: %s\n", msg);
 #ifdef MS_WINDOWS
-       OutputDebugString("Fatal Python error: ");
-       OutputDebugString(msg);
-       OutputDebugString("\n");
+       {
+               size_t len = strlen(msg);
+               WCHAR* buffer;
+               size_t i;
+
+               /* Convert the message to wchar_t. This uses a simple one-to-one
+               conversion, assuming that the this error message actually uses ASCII
+               only. If this ceases to be true, we will have to convert. */
+               buffer = alloca( (len+1) * (sizeof *buffer));
+               for( i=0; i<=len; ++i)
+                       buffer[i] = msg[i];
+               OutputDebugStringW(L"Fatal Python error: ");
+               OutputDebugStringW(buffer);
+               OutputDebugStringW(L"\n");
+       }
 #ifdef _DEBUG
        DebugBreak();
 #endif
diff --git a/README b/README
index 0a5793e7dac3a70b37d1c1981e624da0663c0c5e..a34c9e78465976deaa5d48a9e8ed0990d6d96c45 100644 (file)
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
 This is Python version 2.6.1
 ============================
 
-Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
 Python Software Foundation.
 All rights reserved.