#1370: Finish the merge r58749, log below, by resolving all conflicts in Doc/.

Merged revisions 58221-58741 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r58221 | georg.brandl | 2007-09-20 10:57:59 -0700 (Thu, 20 Sep 2007) | 2 lines

  Patch #1181: add os.environ.clear() method.
........
  r58225 | sean.reifschneider | 2007-09-20 23:33:28 -0700 (Thu, 20 Sep 2007) | 3 lines

  Issue1704287: "make install" fails unless you do "make" first.  Make
     oldsharedmods and sharedmods in "libinstall".
........
  r58232 | guido.van.rossum | 2007-09-22 13:18:03 -0700 (Sat, 22 Sep 2007) | 4 lines

  Patch # 188 by Philip Jenvey.
  Make tell() mark CRLF as a newline.
  With unit test.
........
  r58242 | georg.brandl | 2007-09-24 10:55:47 -0700 (Mon, 24 Sep 2007) | 2 lines

  Fix typo and double word.
........
  r58245 | georg.brandl | 2007-09-24 10:59:28 -0700 (Mon, 24 Sep 2007) | 2 lines

  #1196: document default radix for int().
........
  r58247 | georg.brandl | 2007-09-24 11:08:24 -0700 (Mon, 24 Sep 2007) | 2 lines

  #1177: accept 2xx responses for https too, not only http.
........
  r58249 | andrew.kuchling | 2007-09-24 16:45:51 -0700 (Mon, 24 Sep 2007) | 1 line

  Remove stray odd character; grammar fix
........
  r58250 | andrew.kuchling | 2007-09-24 16:46:28 -0700 (Mon, 24 Sep 2007) | 1 line

  Typo fix
........
  r58251 | andrew.kuchling | 2007-09-24 17:09:42 -0700 (Mon, 24 Sep 2007) | 1 line

  Add various items
........
  r58268 | vinay.sajip | 2007-09-26 22:34:45 -0700 (Wed, 26 Sep 2007) | 1 line

  Change to flush and close logic to fix #1760556.
........
  r58269 | vinay.sajip | 2007-09-26 22:38:51 -0700 (Wed, 26 Sep 2007) | 1 line

  Change to basicConfig() to fix #1021.
........
  r58270 | georg.brandl | 2007-09-26 23:26:58 -0700 (Wed, 26 Sep 2007) | 2 lines

  #1208: document match object's boolean value.
........
  r58271 | vinay.sajip | 2007-09-26 23:56:13 -0700 (Wed, 26 Sep 2007) | 1 line

  Minor date change.
........
  r58272 | vinay.sajip | 2007-09-27 00:35:10 -0700 (Thu, 27 Sep 2007) | 1 line

  Change to LogRecord.__init__() to fix #1206. Note that archaic use of type(x) == types.DictType is because of keeping 1.5.2 compatibility. While this is much less relevant these days, there probably needs to be a separate commit for removing all archaic constructs at the same time.
........
  r58288 | brett.cannon | 2007-09-30 12:45:10 -0700 (Sun, 30 Sep 2007) | 9 lines

  tuple.__repr__ did not consider a reference loop as it is not possible from
  Python code; but it is possible from C.  object.__str__ had the issue of not
  expecting a type to doing something within it's tp_str implementation that
  could trigger an infinite recursion, but it could in C code..  Both found
  thanks to BaseException and how it handles its repr.

  Closes issue #1686386.  Thanks to Thomas Herve for taking an initial stab at
  coming up with a solution.
........
  r58289 | brett.cannon | 2007-09-30 13:37:19 -0700 (Sun, 30 Sep 2007) | 3 lines

  Fix error introduced by r58288; if a tuple is length 0 return its repr and
  don't worry about any self-referring tuples.
........
  r58294 | facundo.batista | 2007-10-02 10:01:24 -0700 (Tue, 02 Oct 2007) | 11 lines


  Made the various is_* operations return booleans.  This was discussed
  with Cawlishaw by mail, and he basically confirmed that to these is_*
  operations, there's no need to return Decimal(0) and Decimal(1) if
  the language supports the False and True booleans.

  Also added a few tests for the these functions in extra.decTest, since
  they are mostly untested (apart from the doctests).

  Thanks Mark Dickinson
........
  r58295 | facundo.batista | 2007-10-02 11:21:18 -0700 (Tue, 02 Oct 2007) | 4 lines


  Added a class to store the digits of log(10), so that they can be made
  available when necessary without recomputing.  Thanks Mark Dickinson
........
  r58299 | mark.summerfield | 2007-10-03 01:53:21 -0700 (Wed, 03 Oct 2007) | 4 lines

  Added note in footnote about string comparisons about
  unicodedata.normalize().
........
  r58304 | raymond.hettinger | 2007-10-03 14:18:11 -0700 (Wed, 03 Oct 2007) | 1 line

  enumerate() is no longer bounded to using sequences shorter than LONG_MAX.  The possibility of overflow was sending some newsgroup posters into a tizzy.
........
  r58305 | raymond.hettinger | 2007-10-03 17:20:27 -0700 (Wed, 03 Oct 2007) | 1 line

  itertools.count() no longer limited to sys.maxint.
........
  r58306 | kurt.kaiser | 2007-10-03 18:49:54 -0700 (Wed, 03 Oct 2007) | 3 lines

  Assume that the user knows when he wants to end the line; don't insert
  something he didn't select or complete.
........
  r58307 | kurt.kaiser | 2007-10-03 19:07:50 -0700 (Wed, 03 Oct 2007) | 2 lines

  Remove unused theme that was causing a fault in p3k.
........
  r58308 | kurt.kaiser | 2007-10-03 19:09:17 -0700 (Wed, 03 Oct 2007) | 2 lines

  Clean up EditorWindow close.
........
  r58309 | kurt.kaiser | 2007-10-03 19:53:07 -0700 (Wed, 03 Oct 2007) | 7 lines

  textView cleanup. Patch 1718043 Tal Einat.

  M    idlelib/EditorWindow.py
  M    idlelib/aboutDialog.py
  M    idlelib/textView.py
  M    idlelib/NEWS.txt
........
  r58310 | kurt.kaiser | 2007-10-03 20:11:12 -0700 (Wed, 03 Oct 2007) | 3 lines

  configDialog cleanup. Patch 1730217 Tal Einat.
........
  r58311 | neal.norwitz | 2007-10-03 23:00:48 -0700 (Wed, 03 Oct 2007) | 4 lines

  Coverity #151: Remove deadcode.

  All this code already exists above starting at line 653.
........
  r58325 | fred.drake | 2007-10-04 19:46:12 -0700 (Thu, 04 Oct 2007) | 1 line

  wrap lines to <80 characters before fixing errors
........
  r58326 | raymond.hettinger | 2007-10-04 19:47:07 -0700 (Thu, 04 Oct 2007) | 6 lines

  Add __asdict__() to NamedTuple and refine the docs.
  Add maxlen support to deque() and fixup docs.
  Partially fix __reduce__().  The None as a third arg was no longer supported.
  Still needs work on __reduce__() to handle recursive inputs.
........
  r58327 | fred.drake | 2007-10-04 19:48:32 -0700 (Thu, 04 Oct 2007) | 3 lines

  move descriptions of ac_(in|out)_buffer_size to the right place
  http://bugs.python.org/issue1053
........
  r58329 | neal.norwitz | 2007-10-04 20:39:17 -0700 (Thu, 04 Oct 2007) | 3 lines

  dict could be NULL, so we need to XDECREF.
  Fix a compiler warning about passing a PyTypeObject* instead of PyObject*.
........
  r58330 | neal.norwitz | 2007-10-04 20:41:19 -0700 (Thu, 04 Oct 2007) | 2 lines

  Fix Coverity #158: Check the correct variable.
........
  r58332 | neal.norwitz | 2007-10-04 22:01:38 -0700 (Thu, 04 Oct 2007) | 7 lines

  Fix Coverity #159.

  This code was broken if save() returned a negative number since i contained
  a boolean value and then we compared i < 0 which should never be true.

  Will backport (assuming it's necessary)
........
  r58334 | neal.norwitz | 2007-10-04 22:29:17 -0700 (Thu, 04 Oct 2007) | 1 line

  Add a note about fixing some more warnings found by Coverity.
........
  r58338 | raymond.hettinger | 2007-10-05 12:07:31 -0700 (Fri, 05 Oct 2007) | 1 line

  Restore BEGIN/END THREADS macros which were squashed in the previous checkin
........
  r58343 | gregory.p.smith | 2007-10-06 00:48:10 -0700 (Sat, 06 Oct 2007) | 3 lines

  Stab in the dark attempt to fix the test_bsddb3 failure on sparc and S-390
  ubuntu buildbots.
........
  r58344 | gregory.p.smith | 2007-10-06 00:51:59 -0700 (Sat, 06 Oct 2007) | 2 lines

  Allows BerkeleyDB 4.6.x >= 4.6.21 for the bsddb module.
........
  r58348 | gregory.p.smith | 2007-10-06 08:47:37 -0700 (Sat, 06 Oct 2007) | 3 lines

  Use the host the author likely meant in the first place.  pop.gmail.com is
  reliable.  gmail.org is someones personal domain.
........
  r58351 | neal.norwitz | 2007-10-06 12:16:28 -0700 (Sat, 06 Oct 2007) | 3 lines

  Ensure that this test will pass even if another test left an unwritable TESTFN.
  Also use the safe unlink in test_support instead of rolling our own here.
........
  r58368 | georg.brandl | 2007-10-08 00:50:24 -0700 (Mon, 08 Oct 2007) | 3 lines

  #1123: fix the docs for the str.split(None, sep) case.
  Also expand a few other methods' docs, which had more info in the deprecated string module docs.
........
  r58369 | georg.brandl | 2007-10-08 01:06:05 -0700 (Mon, 08 Oct 2007) | 2 lines

  Update docstring of sched, also remove an unused assignment.
........
  r58370 | raymond.hettinger | 2007-10-08 02:14:28 -0700 (Mon, 08 Oct 2007) | 5 lines

  Add comments to NamedTuple code.
  Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases).
  Improve the error message in the case of a SyntaxError (caused by a duplicate field name).
........
  r58371 | raymond.hettinger | 2007-10-08 02:56:29 -0700 (Mon, 08 Oct 2007) | 1 line

  Missed a line in the docs
........
  r58372 | raymond.hettinger | 2007-10-08 03:11:51 -0700 (Mon, 08 Oct 2007) | 1 line

  Better variable names
........
  r58376 | georg.brandl | 2007-10-08 07:12:47 -0700 (Mon, 08 Oct 2007) | 3 lines

  #1199: docs for tp_as_{number,sequence,mapping}, by Amaury Forgeot d'Arc.
  No need to merge this to py3k!
........
  r58380 | raymond.hettinger | 2007-10-08 14:26:58 -0700 (Mon, 08 Oct 2007) | 1 line

  Eliminate camelcase function name
........
  r58381 | andrew.kuchling | 2007-10-08 16:23:03 -0700 (Mon, 08 Oct 2007) | 1 line

  Eliminate camelcase function name
........
  r58382 | raymond.hettinger | 2007-10-08 18:36:23 -0700 (Mon, 08 Oct 2007) | 1 line

  Make the error messages more specific
........
  r58384 | gregory.p.smith | 2007-10-08 23:02:21 -0700 (Mon, 08 Oct 2007) | 10 lines

  Splits Modules/_bsddb.c up into bsddb.h and _bsddb.c and adds a C API
  object available as bsddb.db.api.  This is based on the patch submitted
  by Duncan Grisby here:
    http://sourceforge.net/tracker/index.php?func=detail&aid=1551895&group_id=13900&atid=313900
  See this thread for additional info:
    http://sourceforge.net/mailarchive/forum.php?thread_name=E1GAVDK-0002rk-Iw%40apasphere.com&forum_name=pybsddb-users

  It also cleans up the code a little by removing some ifdef/endifs for
  python prior to 2.1 and for unsupported Berkeley DB <= 3.2.
........
  r58385 | gregory.p.smith | 2007-10-08 23:50:43 -0700 (Mon, 08 Oct 2007) | 5 lines

  Fix a double free when positioning a database cursor to a non-existant
  string key (and probably a few other situations with string keys).
  This was reported with a patch as pybsddb sourceforge bug 1708868 by
  jjjhhhlll at gmail.
........
  r58386 | gregory.p.smith | 2007-10-09 00:19:11 -0700 (Tue, 09 Oct 2007) | 3 lines

  Use the highest cPickle protocol in bsddb.dbshelve.  This comes from
  sourceforge pybsddb patch 1551443 by w_barnes.
........
  r58394 | gregory.p.smith | 2007-10-09 11:26:02 -0700 (Tue, 09 Oct 2007) | 2 lines

  remove another sleepycat reference
........
  r58396 | kurt.kaiser | 2007-10-09 12:31:30 -0700 (Tue, 09 Oct 2007) | 3 lines

  Allow interrupt only when executing user code in subprocess
  Patch 1225 Tal Einat modified from IDLE-Spoon.
........
  r58399 | brett.cannon | 2007-10-09 17:07:50 -0700 (Tue, 09 Oct 2007) | 5 lines

  Remove file-level typedefs that were inconsistently used throughout the file.
  Just move over to the public API names.

  Closes issue1238.
........
  r58401 | raymond.hettinger | 2007-10-09 17:26:46 -0700 (Tue, 09 Oct 2007) | 1 line

  Accept Jim Jewett's api suggestion to use None instead of -1 to indicate unbounded deques.
........
  r58403 | kurt.kaiser | 2007-10-09 17:55:40 -0700 (Tue, 09 Oct 2007) | 2 lines

  Allow cursor color change w/o restart. Patch 1725576 Tal Einat.
........
  r58404 | kurt.kaiser | 2007-10-09 18:06:47 -0700 (Tue, 09 Oct 2007) | 2 lines

  show paste if > 80 columns.  Patch 1659326 Tal Einat.
........
  r58415 | thomas.heller | 2007-10-11 12:51:32 -0700 (Thu, 11 Oct 2007) | 5 lines

  On OS X, use os.uname() instead of gestalt.sysv(...) to get the
  operating system version.  This allows to use ctypes when Python
  was configured with --disable-toolbox-glue.
........
  r58419 | neal.norwitz | 2007-10-11 20:01:01 -0700 (Thu, 11 Oct 2007) | 1 line

  Get rid of warning about not being able to create an existing directory.
........
  r58420 | neal.norwitz | 2007-10-11 20:01:30 -0700 (Thu, 11 Oct 2007) | 1 line

  Get rid of warnings on a bunch of platforms by using a proper prototype.
........
  r58421 | neal.norwitz | 2007-10-11 20:01:54 -0700 (Thu, 11 Oct 2007) | 4 lines

  Get rid of compiler warning about retval being used (returned) without
  being initialized.  (gcc warning and Coverity 202)
........
  r58422 | neal.norwitz | 2007-10-11 20:03:23 -0700 (Thu, 11 Oct 2007) | 1 line

  Fix Coverity 168:  Close the file before returning (exiting).
........
  r58423 | neal.norwitz | 2007-10-11 20:04:18 -0700 (Thu, 11 Oct 2007) | 4 lines

  Fix Coverity 180:  Don't overallocate.  We don't need structs, but pointers.
  Also fix a memory leak.
........
  r58424 | neal.norwitz | 2007-10-11 20:05:19 -0700 (Thu, 11 Oct 2007) | 5 lines

  Fix Coverity 185-186:  If the passed in FILE is NULL, uninitialized memory
  would be accessed.

  Will backport.
........
  r58425 | neal.norwitz | 2007-10-11 20:52:34 -0700 (Thu, 11 Oct 2007) | 1 line

  Get this module to compile with bsddb versions prior to 4.3
........
  r58430 | martin.v.loewis | 2007-10-12 01:56:52 -0700 (Fri, 12 Oct 2007) | 3 lines

  Bug #1216: Restore support for Visual Studio 2002.
  Will backport to 2.5.
........
  r58433 | raymond.hettinger | 2007-10-12 10:53:11 -0700 (Fri, 12 Oct 2007) | 1 line

  Fix test of count.__repr__() to ignore the 'L' if the count is a long
........
  r58434 | gregory.p.smith | 2007-10-12 11:44:06 -0700 (Fri, 12 Oct 2007) | 4 lines

  Fixes http://bugs.python.org/issue1233 - bsddb.dbshelve.DBShelf.append
  was useless due to inverted logic.  Also adds a test case for RECNO dbs
  to test_dbshelve.
........
  r58445 | georg.brandl | 2007-10-13 06:20:03 -0700 (Sat, 13 Oct 2007) | 2 lines

  Fix email example.
........
  r58450 | gregory.p.smith | 2007-10-13 16:02:05 -0700 (Sat, 13 Oct 2007) | 2 lines

  Fix an uncollectable reference leak in bsddb.db.DBShelf.append
........
  r58453 | neal.norwitz | 2007-10-13 17:18:40 -0700 (Sat, 13 Oct 2007) | 8 lines

  Let the O/S supply a port if none of the default ports can be used.
  This should make the tests more robust at the expense of allowing
  tests to be sloppier by not requiring them to cleanup after themselves.
  (It will legitamitely help when running two test suites simultaneously
  or if another process is already using one of the predefined ports.)

  Also simplifies (slightLy) the exception handling elsewhere.
........
  r58459 | neal.norwitz | 2007-10-14 11:30:21 -0700 (Sun, 14 Oct 2007) | 2 lines

  Don't raise a string exception, they don't work anymore.
........
  r58460 | neal.norwitz | 2007-10-14 11:40:37 -0700 (Sun, 14 Oct 2007) | 1 line

  Use unittest for assertions
........
  r58468 | armin.rigo | 2007-10-15 00:48:35 -0700 (Mon, 15 Oct 2007) | 2 lines

  test_bigbits was not testing what it seemed to.
........
  r58471 | guido.van.rossum | 2007-10-15 08:54:11 -0700 (Mon, 15 Oct 2007) | 3 lines

  Change a PyErr_Print() into a PyErr_Clear(),
  per discussion in issue 1031213.
........
  r58500 | raymond.hettinger | 2007-10-16 12:18:30 -0700 (Tue, 16 Oct 2007) | 1 line

  Improve error messages
........
  r58506 | raymond.hettinger | 2007-10-16 14:28:32 -0700 (Tue, 16 Oct 2007) | 1 line

  More docs, error messages, and tests
........
  r58507 | andrew.kuchling | 2007-10-16 15:58:03 -0700 (Tue, 16 Oct 2007) | 1 line

  Add items
........
  r58508 | brett.cannon | 2007-10-16 16:24:06 -0700 (Tue, 16 Oct 2007) | 3 lines

  Remove ``:const:`` notation on None in parameter list.  Since the markup is not
  rendered for parameters it just showed up as ``:const:`None` `` in the output.
........
  r58509 | brett.cannon | 2007-10-16 16:26:45 -0700 (Tue, 16 Oct 2007) | 3 lines

  Re-order some functions whose parameters differ between PyObject and const char
  * so that they are next to each other.
........
  r58522 | armin.rigo | 2007-10-17 11:46:37 -0700 (Wed, 17 Oct 2007) | 5 lines

  Fix the overflow checking of list_repeat.
  Introduce overflow checking into list_inplace_repeat.

  Backport candidate, possibly.
........
  r58530 | facundo.batista | 2007-10-17 20:16:03 -0700 (Wed, 17 Oct 2007) | 7 lines


  Issue #1580738.  When HTTPConnection reads the whole stream with read(),
  it closes itself.  When the stream is read in several calls to read(n),
  it should behave in the same way if HTTPConnection knows where the end
  of the stream is (through self.length).  Added a test case for this
  behaviour.
........
  r58531 | facundo.batista | 2007-10-17 20:44:48 -0700 (Wed, 17 Oct 2007) | 3 lines


  Issue 1289, just a typo.
........
  r58532 | gregory.p.smith | 2007-10-18 00:56:54 -0700 (Thu, 18 Oct 2007) | 4 lines

  cleanup test_dbtables to use mkdtemp.  cleanup dbtables to pass txn as a
  keyword argument whenever possible to avoid bugs and confusion.  (dbtables.py
  line 447 self.db.get using txn as a non-keyword was an actual bug due to this)
........
  r58533 | gregory.p.smith | 2007-10-18 01:34:20 -0700 (Thu, 18 Oct 2007) | 4 lines

  Fix a weird bug in dbtables: if it chose a random rowid string that contained
  NULL bytes it would cause the database all sorts of problems in the future
  leading to very strange random failures and corrupt dbtables.bsdTableDb dbs.
........
  r58534 | gregory.p.smith | 2007-10-18 09:32:02 -0700 (Thu, 18 Oct 2007) | 3 lines

  A cleaner fix than the one committed last night.  Generate random rowids that
  do not contain null bytes.
........
  r58537 | gregory.p.smith | 2007-10-18 10:17:57 -0700 (Thu, 18 Oct 2007) | 2 lines

  mention bsddb fixes.
........
  r58538 | raymond.hettinger | 2007-10-18 14:13:06 -0700 (Thu, 18 Oct 2007) | 1 line

  Remove useless warning
........
  r58539 | gregory.p.smith | 2007-10-19 00:31:20 -0700 (Fri, 19 Oct 2007) | 2 lines

  squelch the warning that this test is supposed to trigger.
........
  r58542 | georg.brandl | 2007-10-19 05:32:39 -0700 (Fri, 19 Oct 2007) | 2 lines

  Clarify wording for apply().
........
  r58544 | mark.summerfield | 2007-10-19 05:48:17 -0700 (Fri, 19 Oct 2007) | 3 lines

  Added a cross-ref to each other.
........
  r58545 | georg.brandl | 2007-10-19 10:38:49 -0700 (Fri, 19 Oct 2007) | 2 lines

  #1284: "S" means "seen", not unread.
........
  r58548 | thomas.heller | 2007-10-19 11:11:41 -0700 (Fri, 19 Oct 2007) | 4 lines

  Fix ctypes on 32-bit systems when Python is configured --with-system-ffi.
  See also https://bugs.launchpad.net/bugs/72505.

  Ported from release25-maint branch.
........
  r58550 | facundo.batista | 2007-10-19 12:25:57 -0700 (Fri, 19 Oct 2007) | 8 lines


  The constructor from tuple was way too permissive: it allowed bad
  coefficient numbers, floats in the sign, and other details that
  generated directly the wrong number in the best case, or triggered
  misfunctionality in the alorithms.

  Test cases added for these issues. Thanks Mark Dickinson.
........
  r58559 | georg.brandl | 2007-10-20 06:22:53 -0700 (Sat, 20 Oct 2007) | 2 lines

  Fix code being interpreted as a target.
........
  r58561 | georg.brandl | 2007-10-20 06:36:24 -0700 (Sat, 20 Oct 2007) | 2 lines

  Document new "cmdoption" directive.
........
  r58562 | georg.brandl | 2007-10-20 08:21:22 -0700 (Sat, 20 Oct 2007) | 2 lines

  Make a path more Unix-standardy.
........
  r58564 | georg.brandl | 2007-10-20 10:51:39 -0700 (Sat, 20 Oct 2007) | 2 lines

  Document new directive "envvar".
........
  r58567 | georg.brandl | 2007-10-20 11:08:14 -0700 (Sat, 20 Oct 2007) | 6 lines

  * Add new toplevel chapter, "Using Python." (how to install,
    configure and setup python on different platforms -- at least
    in theory.)
  * Move the Python on Mac docs in that chapter.
  * Add a new chapter about the command line invocation, by stargaming.
........
  r58568 | georg.brandl | 2007-10-20 11:33:20 -0700 (Sat, 20 Oct 2007) | 2 lines

  Change title, for now.
........
  r58569 | georg.brandl | 2007-10-20 11:39:25 -0700 (Sat, 20 Oct 2007) | 2 lines

  Add entry to ACKS.
........
  r58570 | georg.brandl | 2007-10-20 12:05:45 -0700 (Sat, 20 Oct 2007) | 2 lines

  Clarify -E docs.
........
  r58571 | georg.brandl | 2007-10-20 12:08:36 -0700 (Sat, 20 Oct 2007) | 2 lines

  Even more clarification.
........
  r58572 | andrew.kuchling | 2007-10-20 12:25:37 -0700 (Sat, 20 Oct 2007) | 1 line

  Fix protocol name
........
  r58573 | andrew.kuchling | 2007-10-20 12:35:18 -0700 (Sat, 20 Oct 2007) | 1 line

  Various items
........
  r58574 | andrew.kuchling | 2007-10-20 12:39:35 -0700 (Sat, 20 Oct 2007) | 1 line

  Use correct header line
........
  r58576 | armin.rigo | 2007-10-21 02:14:15 -0700 (Sun, 21 Oct 2007) | 3 lines

  Add a crasher for the long-standing issue with closing a file
  while another thread uses it.
........
  r58577 | georg.brandl | 2007-10-21 03:01:56 -0700 (Sun, 21 Oct 2007) | 2 lines

  Remove duplicate crasher.
........
  r58578 | georg.brandl | 2007-10-21 03:24:20 -0700 (Sun, 21 Oct 2007) | 2 lines

  Unify "byte code" to "bytecode". Also sprinkle :term: markup for it.
........
  r58579 | georg.brandl | 2007-10-21 03:32:54 -0700 (Sun, 21 Oct 2007) | 2 lines

  Add markup to new function descriptions.
........
  r58580 | georg.brandl | 2007-10-21 03:45:46 -0700 (Sun, 21 Oct 2007) | 2 lines

  Add :term:s for descriptors.
........
  r58581 | georg.brandl | 2007-10-21 03:46:24 -0700 (Sun, 21 Oct 2007) | 2 lines

  Unify "file-descriptor" to "file descriptor".
........
  r58582 | georg.brandl | 2007-10-21 03:52:38 -0700 (Sun, 21 Oct 2007) | 2 lines

  Add :term: for generators.
........
  r58583 | georg.brandl | 2007-10-21 05:10:28 -0700 (Sun, 21 Oct 2007) | 2 lines

  Add :term:s for iterator.
........
  r58584 | georg.brandl | 2007-10-21 05:15:05 -0700 (Sun, 21 Oct 2007) | 2 lines

  Add :term:s for "new-style class".
........
  r58588 | neal.norwitz | 2007-10-21 21:47:54 -0700 (Sun, 21 Oct 2007) | 1 line

  Add Chris Monson so he can edit PEPs.
........
  r58594 | guido.van.rossum | 2007-10-22 09:27:19 -0700 (Mon, 22 Oct 2007) | 4 lines

  Issue #1307, patch by Derek Shockey.
  When "MAIL" is received without args, an exception happens instead of
  sending a 501 syntax error response.
........
  r58598 | travis.oliphant | 2007-10-22 19:40:56 -0700 (Mon, 22 Oct 2007) | 1 line

  Add phuang patch from Issue 708374 which adds offset parameter to mmap module.
........
  r58601 | neal.norwitz | 2007-10-22 22:44:27 -0700 (Mon, 22 Oct 2007) | 2 lines

  Bug #1313, fix typo (wrong variable name) in example.
........
  r58609 | georg.brandl | 2007-10-23 11:21:35 -0700 (Tue, 23 Oct 2007) | 2 lines

  Update Pygments version from externals.
........
  r58618 | guido.van.rossum | 2007-10-23 12:25:41 -0700 (Tue, 23 Oct 2007) | 3 lines

  Issue 1307 by Derek Shockey, fox the same bug for RCPT.
  Neal: please backport!
........
  r58620 | raymond.hettinger | 2007-10-23 13:37:41 -0700 (Tue, 23 Oct 2007) | 1 line

  Shorter name for namedtuple()
........
  r58621 | andrew.kuchling | 2007-10-23 13:55:47 -0700 (Tue, 23 Oct 2007) | 1 line

  Update name
........
  r58622 | raymond.hettinger | 2007-10-23 14:23:07 -0700 (Tue, 23 Oct 2007) | 1 line

  Fixup news entry
........
  r58623 | raymond.hettinger | 2007-10-23 18:28:33 -0700 (Tue, 23 Oct 2007) | 1 line

  Optimize sum() for integer and float inputs.
........
  r58624 | raymond.hettinger | 2007-10-23 19:05:51 -0700 (Tue, 23 Oct 2007) | 1 line

  Fixup error return and add support for intermixed ints and floats/
........
  r58628 | vinay.sajip | 2007-10-24 03:47:06 -0700 (Wed, 24 Oct 2007) | 1 line

  Bug #1321: Fixed logic error in TimedRotatingFileHandler.__init__()
........
  r58641 | facundo.batista | 2007-10-24 12:11:08 -0700 (Wed, 24 Oct 2007) | 4 lines


  Issue 1290.  CharacterData.__repr__ was constructing a string
  in response that keeped having a non-ascii character.
........
  r58643 | thomas.heller | 2007-10-24 12:50:45 -0700 (Wed, 24 Oct 2007) | 1 line

  Added unittest for calling a function with paramflags (backport from py3k branch).
........
  r58645 | matthias.klose | 2007-10-24 13:00:44 -0700 (Wed, 24 Oct 2007) | 2 lines

  - Build using system ffi library on arm*-linux*.
........
  r58651 | georg.brandl | 2007-10-24 14:40:38 -0700 (Wed, 24 Oct 2007) | 2 lines

  Bug #1287: make os.environ.pop() work as expected.
........
  r58652 | raymond.hettinger | 2007-10-24 19:26:58 -0700 (Wed, 24 Oct 2007) | 1 line

  Missing DECREFs
........
  r58653 | matthias.klose | 2007-10-24 23:37:24 -0700 (Wed, 24 Oct 2007) | 2 lines

  - Build using system ffi library on arm*-linux*, pass --with-system-ffi to CONFIG_ARGS
........
  r58655 | thomas.heller | 2007-10-25 12:47:32 -0700 (Thu, 25 Oct 2007) | 2 lines

  ffi_type_longdouble may be already #defined.
  See issue 1324.
........
  r58656 | kurt.kaiser | 2007-10-25 15:43:45 -0700 (Thu, 25 Oct 2007) | 3 lines

  Correct an ancient bug in an unused path by removing that path: register() is
  now idempotent.
........
  r58660 | kurt.kaiser | 2007-10-25 17:10:09 -0700 (Thu, 25 Oct 2007) | 4 lines

  1. Add comments to provide top-level documentation.
  2. Refactor to use more descriptive names.
  3. Enhance tests in main().
........
  r58675 | georg.brandl | 2007-10-26 11:30:41 -0700 (Fri, 26 Oct 2007) | 2 lines

  Fix new pop() method on os.environ on ignorecase-platforms.
........
  r58696 | neal.norwitz | 2007-10-27 15:32:21 -0700 (Sat, 27 Oct 2007) | 1 line

  Update URL for Pygments.  0.8.1 is no longer available
........
  r58697 | hyeshik.chang | 2007-10-28 04:19:02 -0700 (Sun, 28 Oct 2007) | 3 lines

  - Add support for FreeBSD 8 which is recently forked from FreeBSD 7.
  - Regenerate IN module for most recent maintenance tree of FreeBSD 6 and 7.
........
  r58698 | hyeshik.chang | 2007-10-28 05:38:09 -0700 (Sun, 28 Oct 2007) | 2 lines

  Enable platform-specific tweaks for FreeBSD 8 (exactly same to FreeBSD 7's yet)
........
  r58700 | kurt.kaiser | 2007-10-28 12:03:59 -0700 (Sun, 28 Oct 2007) | 2 lines

  Add confirmation dialog before printing.  Patch 1717170 Tal Einat.
........
  r58706 | guido.van.rossum | 2007-10-29 13:52:45 -0700 (Mon, 29 Oct 2007) | 3 lines

  Patch 1353 by Jacob Winther.
  Add mp4 mapping to mimetypes.py.
........
  r58709 | guido.van.rossum | 2007-10-29 15:15:05 -0700 (Mon, 29 Oct 2007) | 6 lines

  Backport fixes for the code that decodes octal escapes (and for PyString
  also hex escapes) -- this was reaching beyond the end of the input string
  buffer, even though it is not supposed to be \0-terminated.
  This has no visible effect but is clearly the correct thing to do.
  (In 3.0 it had a visible effect after removing ob_sstate from PyString.)
........
  r58710 | kurt.kaiser | 2007-10-29 19:38:54 -0700 (Mon, 29 Oct 2007) | 7 lines

  check in Tal Einat's update to tabpage.py
  Patch 1612746

  M    configDialog.py
  M    NEWS.txt
  AM   tabbedpages.py
........
  r58715 | georg.brandl | 2007-10-30 10:51:18 -0700 (Tue, 30 Oct 2007) | 2 lines

  Use correct markup.
........
  r58716 | georg.brandl | 2007-10-30 10:57:12 -0700 (Tue, 30 Oct 2007) | 2 lines

  Make example about hiding None return values at the prompt clearer.
........
  r58728 | neal.norwitz | 2007-10-30 23:33:20 -0700 (Tue, 30 Oct 2007) | 1 line

  Fix some compiler warnings for signed comparisons on Unix and Windows.
........
  r58731 | martin.v.loewis | 2007-10-31 10:19:33 -0700 (Wed, 31 Oct 2007) | 2 lines

  Adding Christian Heimes.
........
  r58737 | raymond.hettinger | 2007-10-31 14:57:58 -0700 (Wed, 31 Oct 2007) | 1 line

  Clarify the reasons why pickle is almost always better than marshal
........
  r58739 | raymond.hettinger | 2007-10-31 15:15:49 -0700 (Wed, 31 Oct 2007) | 1 line

  Sets are marshalable.
........
This commit is contained in:
Georg Brandl 2007-11-01 20:32:30 +00:00
parent 8ce8a784bd
commit 9afde1c0de
68 changed files with 806 additions and 747 deletions

View File

@ -104,6 +104,7 @@ docs@python.org), and we'll be glad to correct the problem.
* Detlef Lannert
* Piers Lauder
* Glyph Lefkowitz
* Robert Lehmann
* Marc-André Lemburg
* Ulf A. Lindgren
* Everett Lipman

View File

@ -72,7 +72,7 @@ or by installing it from http://docutils.sf.net/.
You can optionally also install Pygments, either as a checkout via ::
svn co http://svn.python.org/projects/external/Pygments-0.8.1/pygments tools/pygments
svn co http://svn.python.org/projects/external/Pygments-0.9/pygments tools/pygments
or from PyPI at http://pypi.python.org/pypi/Pygments.

View File

@ -31,21 +31,14 @@ Object Protocol
instead of the :func:`repr`.
.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. This
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
always succeeds.
.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
value on success, or *NULL* on failure. This is the equivalent of the Python
expression ``o.attr_name``.
.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. This
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
@ -59,11 +52,11 @@ Object Protocol
expression ``o.attr_name``.
.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
Set the value of the attribute named *attr_name*, for object *o*, to the value
*v*. Returns ``-1`` on failure. This is the equivalent of the Python statement
``o.attr_name = v``.
Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
value on success, or *NULL* on failure. This is the equivalent of the Python
expression ``o.attr_name``.
.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
@ -73,10 +66,11 @@ Object Protocol
``o.attr_name = v``.
.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
This is the equivalent of the Python statement: ``del o.attr_name``.
Set the value of the attribute named *attr_name*, for object *o*, to the value
*v*. Returns ``-1`` on failure. This is the equivalent of the Python statement
``o.attr_name = v``.
.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
@ -85,6 +79,12 @@ Object Protocol
This is the equivalent of the Python statement ``del o.attr_name``.
.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
This is the equivalent of the Python statement ``del o.attr_name``.
.. cfunction:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
Compare the values of *o1* and *o2* using the operation specified by *opid*,
@ -327,7 +327,10 @@ is considered sufficient for this determination.
.. cfunction:: int PyObject_AsFileDescriptor(PyObject *o)
Derives a file-descriptor from a Python object.
Derives a file descriptor from a Python object. If the object is an integer or
long integer, its value is returned. If not, the object's :meth:`fileno` method
is called if it exists; the method must return an integer or long integer, which
is returned as the file descriptor value. Returns ``-1`` on failure.
.. cfunction:: PyObject* PyObject_Dir(PyObject *o)

View File

@ -12,12 +12,6 @@ extension modules or embed Python. It is a companion to :ref:`extending-index`,
which describes the general principles of extension writing but does not
document the API functions in detail.
.. warning::
The current version of this document is somewhat incomplete. However, most of
the important functions, types and structures are described.
.. toctree::
:maxdepth: 2

View File

@ -618,8 +618,8 @@ type objects) *must* have the :attr:`ob_size` field.
objects which implement the mapping protocol. These fields are documented in
:ref:`mapping-structs`.
The :attr:`tp_as_mapping` field is not inherited, but the contained fields are
inherited individually.
The :attr:`tp_as_mapping` field is not inherited, but the contained fields
are inherited individually.
.. cmember:: hashfunc PyTypeObject.tp_hash

View File

@ -6,6 +6,7 @@
whatsnew/3.0.rst
tutorial/index.rst
using/index.rst
reference/index.rst
library/index.rst
extending/index.rst

View File

@ -1199,7 +1199,7 @@ other utility module.
If *force* is true, all files are recompiled regardless of timestamps.
The source filename encoded in each bytecode file defaults to the filenames
The source filename encoded in each :term:`bytecode` file defaults to the filenames
listed in *py_files*; you can modify these with *prefix* and *basedir*.
*prefix* is a string that will be stripped off of each source filename, and
*base_dir* is a directory name that will be prepended (after *prefix* is

View File

@ -311,7 +311,7 @@ will reflect this and now has the form :file:`foo-1.0.win32-py2.0.exe`. You
have to create a separate installer for every Python version you want to
support.
The installer will try to compile pure modules into bytecode after installation
The installer will try to compile pure modules into :term:`bytecode` after installation
on the target system in normal and optimizing mode. If you don't want this to
happen for some reason, you can run the :command:`bdist_wininst` command with
the :option:`--no-target-compile` and/or the :option:`--no-target-optimize`

View File

@ -210,7 +210,20 @@ The directives are:
.. describe:: opcode
Describes a Python bytecode instruction.
Describes a Python :term:`bytecode` instruction.
.. describe:: cmdoption
Describes a command line option or switch. Option argument names should be
enclosed in angle brackets. Example::
.. cmdoption:: -m <module>
Run a module as a script.
.. describe:: envvar
Describes an environment variable that Python uses or defines.
There is also a generic version of these directives:

View File

@ -1110,7 +1110,7 @@ Note that this list does not place any restrictions on the values of the
attributes, when the values are computed, or how relevant data is stored.
When :cfunc:`PyType_Ready` is called, it uses three tables referenced by the
type object to create *descriptors* which are placed in the dictionary of the
type object to create :term:`descriptor`\s which are placed in the dictionary of the
type object. Each descriptor controls access to one attribute of the instance
object. Each of the tables is optional; if all three are *NULL*, instances of
the type will only have attributes that are inherited from their base type, and
@ -1154,7 +1154,7 @@ be read-only or read-write. The structures in the table are defined as::
char *doc;
} PyMemberDef;
For each entry in the table, a descriptor will be constructed and added to the
For each entry in the table, a :term:`descriptor` will be constructed and added to the
type which will be able to extract a value from the instance structure. The
:attr:`type` field should contain one of the type codes defined in the
:file:`structmember.h` header; the value will be used to determine how to

View File

@ -20,13 +20,13 @@ Glossary
Benevolent Dictator For Life, a.k.a. `Guido van Rossum
<http://www.python.org/~guido/>`_, Python's creator.
byte code
The internal representation of a Python program in the interpreter. The
byte code is also cached in ``.pyc`` and ``.pyo`` files so that executing
the same file is faster the second time (recompilation from source to byte
code can be avoided). This "intermediate language" is said to run on a
"virtual machine" that calls the subroutines corresponding to each
bytecode.
bytecode
Python source code is compiled into bytecode, the internal representation
of a Python program in the interpreter. The bytecode is also cached in
``.pyc`` and ``.pyo`` files so that executing the same file is faster the
second time (recompilation from source to bytecode can be avoided). This
"intermediate language" is said to run on a "virtual machine" that calls
the subroutines corresponding to each bytecode.
classic class
One of the two flavors of classes in earlier Python versions. Since
@ -47,12 +47,15 @@ Glossary
descriptor
An object that defines the methods :meth:`__get__`, :meth:`__set__`, or
:meth:`__delete__`. When a class attribute is a descriptor, its special
binding behavior is triggered upon attribute lookup. Normally, writing
*a.b* looks up the object *b* in the class dictionary for *a*, but if *b*
is a descriptor, the defined method gets called. Understanding
descriptors is a key to a deep understanding of Python because they are
the basis for many features including functions, methods, properties,
class methods, static methods, and reference to super classes.
binding behavior is triggered upon attribute lookup. Normally, using
*a.b* to get, set or delete an attribute looks up the object named *b* in
the class dictionary for *a*, but if *b* is a descriptor, the respective
descriptor method gets called. Understanding descriptors is a key to a
deep understanding of Python because they are the basis for many features
including functions, methods, properties, 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
@ -209,6 +212,8 @@ Glossary
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`.
LBYL
Look before you leap. This coding style explicitly tests for
pre-conditions before making calls or lookups. This style contrasts with
@ -237,6 +242,8 @@ Glossary
powerful, elegant solutions. They have been used for logging attribute
access, adding thread-safety, tracking object creation, implementing
singletons, and many other tasks.
More information can be found in :ref:`metaclasses`.
mutable
Mutable objects can change their value but keep their :func:`id`. See
@ -267,6 +274,8 @@ Glossary
earlier Python versions, only new-style classes could use Python's newer,
versatile features like :attr:`__slots__`, descriptors, properties,
:meth:`__getattribute__`, class methods, and static methods.
More information can be found in :ref:`newstyle`.
Python 3000
Nickname for the next major Python version, 3.0 (coined long ago when the

View File

@ -13,8 +13,8 @@ disclaimer.)
In this document, we'll take a tour of Python's features suitable for
implementing programs in a functional style. After an introduction to the
concepts of functional programming, we'll look at language features such as
iterators and generators and relevant library modules such as :mod:`itertools`
and :mod:`functools`.
:term:`iterator`\s and :term:`generator`\s and relevant library modules such as
:mod:`itertools` and :mod:`functools`.
Introduction
@ -448,8 +448,8 @@ Here's the simplest example of a generator function::
yield i
Any function containing a ``yield`` keyword is a generator function; this is
detected by Python's bytecode compiler which compiles the function specially as
a result.
detected by Python's :term:`bytecode` compiler which compiles the function
specially as a result.
When you call a generator function, it doesn't return a single value; instead it
returns a generator object that supports the iterator protocol. On executing

View File

@ -14,7 +14,6 @@ Currently, the HOWTOs are:
:maxdepth: 1
advocacy.rst
pythonmac.rst
curses.rst
doanddont.rst
functional.rst

View File

@ -1,202 +0,0 @@
.. _using-on-mac:
***************************
Using Python on a Macintosh
***************************
:Author: Bob Savage <bobsavage@mac.com>
Python on a Macintosh running Mac OS X is in principle very similar to Python on
any other Unix platform, but there are a number of additional features such as
the IDE and the Package Manager that are worth pointing out.
The Mac-specific modules are documented in :ref:`mac-specific-services`.
Python on Mac OS 9 or earlier can be quite different from Python on Unix or
Windows, but is beyond the scope of this manual, as that platform is no longer
supported, starting with Python 2.4. See http://www.cwi.nl/~jack/macpython for
installers for the latest 2.3 release for Mac OS 9 and related documentation.
.. _getting-osx:
Getting and Installing MacPython
================================
Mac OS X 10.4 comes with Python 2.3 pre-installed by Apple. However, you are
encouraged to install the most recent version of Python from the Python website
(http://www.python.org). A "universal binary" build of Python 2.5, which runs
natively on the Mac's new Intel and legacy PPC CPU's, is available there.
What you get after installing is a number of things:
* A :file:`MacPython 2.5` folder in your :file:`Applications` folder. In here
you find IDLE, the development environment that is a standard part of official
Python distributions; PythonLauncher, which handles double-clicking Python
scripts from the Finder; and the "Build Applet" tool, which allows you to
package Python scripts as standalone applications on your system.
* A framework :file:`/Library/Frameworks/Python.framework`, which includes the
Python executable and libraries. The installer adds this location to your shell
path. To uninstall MacPython, you can simply remove these three things. A
symlink to the Python executable is placed in /usr/local/bin/.
The Apple-provided build of Python is installed in
:file:`/System/Library/Frameworks/Python.framework` and :file:`/usr/bin/python`,
respectively. You should never modify or delete these, as they are
Apple-controlled and are used by Apple- or third-party software.
IDLE includes a help menu that allows you to access Python documentation. If you
are completely new to Python you should start reading the tutorial introduction
in that document.
If you are familiar with Python on other Unix platforms you should read the
section on running Python scripts from the Unix shell.
How to run a Python script
--------------------------
Your best way to get started with Python on Mac OS X is through the IDLE
integrated development environment, see section :ref:`ide` and use the Help menu
when the IDE is running.
If you want to run Python scripts from the Terminal window command line or from
the Finder you first need an editor to create your script. Mac OS X comes with a
number of standard Unix command line editors, :program:`vim` and
:program:`emacs` among them. If you want a more Mac-like editor,
:program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see
http://www.barebones.com/products/bbedit/index.shtml) are good choices, as is
:program:`TextMate` (see http://macromates.com/). Other editors include
:program:`Gvim` (http://macvim.org) and :program:`Aquamacs`
(http://aquamacs.org).
To run your script from the Terminal window you must make sure that
:file:`/usr/local/bin` is in your shell search path.
To run your script from the Finder you have two options:
* Drag it to :program:`PythonLauncher`
* Select :program:`PythonLauncher` as the default application to open your
script (or any .py script) through the finder Info window and double-click it.
:program:`PythonLauncher` has various preferences to control how your script is
launched. Option-dragging allows you to change these for one invocation, or use
its Preferences menu to change things globally.
.. _osx-gui-scripts:
Running scripts with a GUI
--------------------------
With older versions of Python, there is one Mac OS X quirk that you need to be
aware of: programs that talk to the Aqua window manager (in other words,
anything that has a GUI) need to be run in a special way. Use :program:`pythonw`
instead of :program:`python` to start such scripts.
With Python 2.5, you can use either :program:`python` or :program:`pythonw`.
Configuration
-------------
Python on OS X honors all standard Unix environment variables such as
:envvar:`PYTHONPATH`, but setting these variables for programs started from the
Finder is non-standard as the Finder does not read your :file:`.profile` or
:file:`.cshrc` at startup. You need to create a file :file:`~
/.MacOSX/environment.plist`. See Apple's Technical Document QA1067 for details.
For more information on installation Python packages in MacPython, see section
:ref:`mac-package-manager`.
.. _ide:
The IDE
=======
MacPython ships with the standard IDLE development environment. A good
introduction to using IDLE can be found at http://hkn.eecs.berkeley.edu/
dyoo/python/idle_intro/index.html.
.. _mac-package-manager:
Installing Additional Python Packages
=====================================
There are several methods to install additional Python packages:
* http://pythonmac.org/packages/ contains selected compiled packages for Python
2.5, 2.4, and 2.3.
* Packages can be installed via the standard Python distutils mode (``python
setup.py install``).
* Many packages can also be installed via the :program:`setuptools` extension.
GUI Programming on the Mac
==========================
There are several options for building GUI applications on the Mac with Python.
*PyObjC* is a Python binding to Apple's Objective-C/Cocoa framework, which is
the foundation of most modern Mac development. Information on PyObjC is
available from http://pyobjc.sourceforge.net.
The standard Python GUI toolkit is :mod:`Tkinter`, based on the cross-platform
Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS
X by Apple, and the latest version can be downloaded and installed from
http://www.activestate.com; it can also be built from source.
*wxPython* is another popular cross-platform GUI toolkit that runs natively on
Mac OS X. Packages and documentation are available from http://www.wxpython.org.
*PyQt* is another popular cross-platform GUI toolkit that runs natively on Mac
OS X. More information can be found at
http://www.riverbankcomputing.co.uk/pyqt/.
Distributing Python Applications on the Mac
===========================================
The "Build Applet" tool that is placed in the MacPython 2.5 folder is fine for
packaging small Python scripts on your own machine to run as a standard Mac
application. This tool, however, is not robust enough to distribute Python
applications to other users.
The standard tool for deploying standalone Python applications on the Mac is
:program:`py2app`. More information on installing and using py2app can be found
at http://undefined.org/python/#py2app.
Application Scripting
=====================
Python can also be used to script other Mac applications via Apple's Open
Scripting Architecture (OSA); see http://appscript.sourceforge.net. Appscript is
a high-level, user-friendly Apple event bridge that allows you to control
scriptable Mac OS X applications using ordinary Python scripts. Appscript makes
Python a serious alternative to Apple's own *AppleScript* language for
automating your Mac. A related package, *PyOSA*, is an OSA language component
for the Python scripting language, allowing Python code to be executed by any
OSA-enabled application (Script Editor, Mail, iTunes, etc.). PyOSA makes Python
a full peer to AppleScript.
Other Resources
===============
The MacPython mailing list is an excellent support resource for Python users and
developers on the Mac:
http://www.python.org/community/sigs/current/pythonmac-sig/
Another useful resource is the MacPython wiki:
http://wiki.python.org/moin/MacPython

View File

@ -354,7 +354,7 @@ listing.
| | returns them as a list. |
+------------------+-----------------------------------------------+
| ``finditer()`` | Find all substrings where the RE matches, and |
| | returns them as an iterator. |
| | returns them as an :term:`iterator`. |
+------------------+-----------------------------------------------+
:meth:`match` and :meth:`search` return ``None`` if no match can be found. If
@ -460,7 +460,7 @@ Two :class:`RegexObject` methods return all of the matches for a pattern.
:meth:`findall` has to create the entire list before it can be returned as the
result. The :meth:`finditer` method returns a sequence of :class:`MatchObject`
instances as an iterator. [#]_ ::
instances as an :term:`iterator`. [#]_ ::
>>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')
>>> iterator

View File

@ -53,7 +53,7 @@ Usage: %prog [options] msgfile
# email message can't be used to overwrite important files
filename = part.get_filename()
if not filename:
ext = mimetypes.guess_extension(part.get_type())
ext = mimetypes.guess_extension(part.get_content_type())
if not ext:
# Use a generic bag-of-bits extension
ext = '.bin'

View File

@ -12,7 +12,7 @@ Abstract Syntax Trees
The ``_ast`` module helps Python applications to process trees of the Python
abstract syntax grammar. The Python compiler currently provides read-only access
to such trees, meaning that applications can only create a tree for a given
piece of Python source code; generating byte code from a (potentially modified)
piece of Python source code; generating :term:`bytecode` from a (potentially modified)
tree is not supported. The abstract syntax itself might change with each Python
release; this module helps to find out programmatically what the current grammar
looks like.

View File

@ -9,72 +9,90 @@
This module builds on the :mod:`asyncore` infrastructure, simplifying
asynchronous clients and servers and making it easier to handle protocols whose
elements are terminated by arbitrary strings, or are of variable length.
asynchronous clients and servers and making it easier to handle protocols
whose elements are terminated by arbitrary strings, or are of variable length.
:mod:`asynchat` defines the abstract class :class:`async_chat` that you
subclass, providing implementations of the :meth:`collect_incoming_data` and
:meth:`found_terminator` methods. It uses the same asynchronous loop as
:mod:`asyncore`, and the two types of channel, :class:`asyncore.dispatcher` and
:class:`asynchat.async_chat`, can freely be mixed in the channel map. Typically
an :class:`asyncore.dispatcher` server channel generates new
:class:`asynchat.async_chat` channel objects as it receives incoming connection
requests.
:mod:`asyncore`, and the two types of channel, :class:`asyncore.dispatcher`
and :class:`asynchat.async_chat`, can freely be mixed in the channel map.
Typically an :class:`asyncore.dispatcher` server channel generates new
:class:`asynchat.async_chat` channel objects as it receives incoming
connection requests.
.. class:: async_chat()
This class is an abstract subclass of :class:`asyncore.dispatcher`. To make
practical use of the code you must subclass :class:`async_chat`, providing
meaningful :meth:`collect_incoming_data` and :meth:`found_terminator` methods.
meaningful :meth:`collect_incoming_data` and :meth:`found_terminator`
methods.
The :class:`asyncore.dispatcher` methods can be used, although not all make
sense in a message/response context.
Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of events
that are generated by an analysis of socket conditions after a :cfunc:`select`
call. Once the polling loop has been started the :class:`async_chat` object's
methods are called by the event-processing framework with no action on the part
of the programmer.
Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of
events that are generated by an analysis of socket conditions after a
:cfunc:`select` call. Once the polling loop has been started the
:class:`async_chat` object's methods are called by the event-processing
framework with no action on the part of the programmer.
Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to define a
first-in-first-out queue (fifo) of *producers*. A producer need have only one
method, :meth:`more`, which should return data to be transmitted on the channel.
Two class attributes can be modified, to improve performance, or possibly
even to conserve memory.
.. data:: ac_in_buffer_size
The asynchronous input buffer size (default ``4096``).
.. data:: ac_out_buffer_size
The asynchronous output buffer size (default ``4096``).
Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to
define a first-in-first-out queue (fifo) of *producers*. A producer need
have only one method, :meth:`more`, which should return data to be
transmitted on the channel.
The producer indicates exhaustion (*i.e.* that it contains no more data) by
having its :meth:`more` method return the empty string. At this point the
:class:`async_chat` object removes the producer from the fifo and starts using
the next producer, if any. When the producer fifo is empty the
:class:`async_chat` object removes the producer from the fifo and starts
using the next producer, if any. When the producer fifo is empty the
:meth:`handle_write` method does nothing. You use the channel object's
:meth:`set_terminator` method to describe how to recognize the end of, or an
important breakpoint in, an incoming transmission from the remote endpoint.
:meth:`set_terminator` method to describe how to recognize the end of, or
an important breakpoint in, an incoming transmission from the remote
endpoint.
To build a functioning :class:`async_chat` subclass your input methods
:meth:`collect_incoming_data` and :meth:`found_terminator` must handle the data
that the channel receives asynchronously. The methods are described below.
:meth:`collect_incoming_data` and :meth:`found_terminator` must handle the
data that the channel receives asynchronously. The methods are described
below.
.. method:: async_chat.close_when_done()
Pushes a ``None`` on to the producer fifo. When this producer is popped off the
fifo it causes the channel to be closed.
Pushes a ``None`` on to the producer fifo. When this producer is popped off
the fifo it causes the channel to be closed.
.. method:: async_chat.collect_incoming_data(data)
Called with *data* holding an arbitrary amount of received data. The default
method, which must be overridden, raises a :exc:`NotImplementedError` exception.
Called with *data* holding an arbitrary amount of received data. The
default method, which must be overridden, raises a
:exc:`NotImplementedError` exception.
.. method:: async_chat.discard_buffers()
In emergencies this method will discard any data held in the input and/or output
buffers and the producer fifo.
In emergencies this method will discard any data held in the input and/or
output buffers and the producer fifo.
.. method:: async_chat.found_terminator()
Called when the incoming data stream matches the termination condition set by
:meth:`set_terminator`. The default method, which must be overridden, raises a
:exc:`NotImplementedError` exception. The buffered input data should be
available via an instance attribute.
Called when the incoming data stream matches the termination condition set
by :meth:`set_terminator`. The default method, which must be overridden,
raises a :exc:`NotImplementedError` exception. The buffered input data
should be available via an instance attribute.
.. method:: async_chat.get_terminator()
@ -90,59 +108,59 @@ requests.
.. method:: async_chat.handle_read()
Called when a read event fires on the channel's socket in the asynchronous loop.
The default method checks for the termination condition established by
:meth:`set_terminator`, which can be either the appearance of a particular
string in the input stream or the receipt of a particular number of characters.
When the terminator is found, :meth:`handle_read` calls the
:meth:`found_terminator` method after calling :meth:`collect_incoming_data` with
any data preceding the terminating condition.
Called when a read event fires on the channel's socket in the asynchronous
loop. The default method checks for the termination condition established
by :meth:`set_terminator`, which can be either the appearance of a
particular string in the input stream or the receipt of a particular number
of characters. When the terminator is found, :meth:`handle_read` calls the
:meth:`found_terminator` method after calling :meth:`collect_incoming_data`
with any data preceding the terminating condition.
.. method:: async_chat.handle_write()
Called when the application may write data to the channel. The default method
calls the :meth:`initiate_send` method, which in turn will call
:meth:`refill_buffer` to collect data from the producer fifo associated with the
channel.
Called when the application may write data to the channel. The default
method calls the :meth:`initiate_send` method, which in turn will call
:meth:`refill_buffer` to collect data from the producer fifo associated
with the channel.
.. method:: async_chat.push(data)
Creates a :class:`simple_producer` object (*see below*) containing the data and
pushes it on to the channel's ``producer_fifo`` to ensure its transmission. This
is all you need to do to have the channel write the data out to the network,
although it is possible to use your own producers in more complex schemes to
implement encryption and chunking, for example.
Creates a :class:`simple_producer` object (*see below*) containing the data
and pushes it on to the channel's ``producer_fifo`` to ensure its
transmission. This is all you need to do to have the channel write the
data out to the network, although it is possible to use your own producers
in more complex schemes to implement encryption and chunking, for example.
.. method:: async_chat.push_with_producer(producer)
Takes a producer object and adds it to the producer fifo associated with the
channel. When all currently-pushed producers have been exhausted the channel
will consume this producer's data by calling its :meth:`more` method and send
the data to the remote endpoint.
Takes a producer object and adds it to the producer fifo associated with
the channel. When all currently-pushed producers have been exhausted the
channel will consume this producer's data by calling its :meth:`more`
method and send the data to the remote endpoint.
.. method:: async_chat.readable()
Should return ``True`` for the channel to be included in the set of channels
tested by the :cfunc:`select` loop for readability.
Should return ``True`` for the channel to be included in the set of
channels tested by the :cfunc:`select` loop for readability.
.. method:: async_chat.refill_buffer()
Refills the output buffer by calling the :meth:`more` method of the producer at
the head of the fifo. If it is exhausted then the producer is popped off the
fifo and the next producer is activated. If the current producer is, or becomes,
``None`` then the channel is closed.
Refills the output buffer by calling the :meth:`more` method of the
producer at the head of the fifo. If it is exhausted then the producer is
popped off the fifo and the next producer is activated. If the current
producer is, or becomes, ``None`` then the channel is closed.
.. method:: async_chat.set_terminator(term)
Sets the terminating condition to be recognised on the channel. ``term`` may be
any of three types of value, corresponding to three different ways to handle
incoming protocol data.
Sets the terminating condition to be recognized on the channel. ``term``
may be any of three types of value, corresponding to three different ways
to handle incoming protocol data.
+-----------+---------------------------------------------+
| term | Description |
@ -158,8 +176,8 @@ requests.
| | forever |
+-----------+---------------------------------------------+
Note that any data following the terminator will be available for reading by the
channel after :meth:`found_terminator` is called.
Note that any data following the terminator will be available for reading
by the channel after :meth:`found_terminator` is called.
.. method:: async_chat.writable()
@ -174,29 +192,29 @@ asynchat - Auxiliary Classes and Functions
.. class:: simple_producer(data[, buffer_size=512])
A :class:`simple_producer` takes a chunk of data and an optional buffer size.
Repeated calls to its :meth:`more` method yield successive chunks of the data no
larger than *buffer_size*.
A :class:`simple_producer` takes a chunk of data and an optional buffer
size. Repeated calls to its :meth:`more` method yield successive chunks of
the data no larger than *buffer_size*.
.. method:: simple_producer.more()
Produces the next chunk of information from the producer, or returns the empty
string.
Produces the next chunk of information from the producer, or returns the
empty string.
.. class:: fifo([list=None])
Each channel maintains a :class:`fifo` holding data which has been pushed by the
application but not yet popped for writing to the channel. A :class:`fifo` is a
list used to hold data and/or producers until they are required. If the *list*
argument is provided then it should contain producers or data items to be
written to the channel.
Each channel maintains a :class:`fifo` holding data which has been pushed
by the application but not yet popped for writing to the channel. A
:class:`fifo` is a list used to hold data and/or producers until they are
required. If the *list* argument is provided then it should contain
producers or data items to be written to the channel.
.. method:: fifo.is_empty()
Returns ``True`` iff the fifo is empty.
Returns ``True`` if and only if the fifo is empty.
.. method:: fifo.first()
@ -206,14 +224,14 @@ asynchat - Auxiliary Classes and Functions
.. method:: fifo.push(data)
Adds the given data (which may be a string or a producer object) to the producer
fifo.
Adds the given data (which may be a string or a producer object) to the
producer fifo.
.. method:: fifo.pop()
If the fifo is not empty, returns ``True, first()``, deleting the popped item.
Returns ``False, None`` for an empty fifo.
If the fifo is not empty, returns ``True, first()``, deleting the popped
item. Returns ``False, None`` for an empty fifo.
The :mod:`asynchat` module also defines one utility function, which may be of
use in network and textual analysis operations.
@ -221,8 +239,8 @@ use in network and textual analysis operations.
.. function:: find_prefix_at_end(haystack, needle)
Returns ``True`` if string *haystack* ends with any non-empty prefix of string
*needle*.
Returns ``True`` if string *haystack* ends with any non-empty prefix of
string *needle*.
.. _asynchat-example:
@ -231,19 +249,20 @@ asynchat Example
----------------
The following partial example shows how HTTP requests can be read with
:class:`async_chat`. A web server might create an :class:`http_request_handler`
object for each incoming client connection. Notice that initially the channel
terminator is set to match the blank line at the end of the HTTP headers, and a
flag indicates that the headers are being read.
:class:`async_chat`. A web server might create an
:class:`http_request_handler` object for each incoming client connection.
Notice that initially the channel terminator is set to match the blank line at
the end of the HTTP headers, and a flag indicates that the headers are being
read.
Once the headers have been read, if the request is of type POST (indicating that
further data are present in the input stream) then the ``Content-Length:``
header is used to set a numeric terminator to read the right amount of data from
the channel.
Once the headers have been read, if the request is of type POST (indicating
that further data are present in the input stream) then the
``Content-Length:`` header is used to set a numeric terminator to read the
right amount of data from the channel.
The :meth:`handle_request` method is called once all relevant input has been
marshalled, after setting the channel terminator to ``None`` to ensure that any
extraneous data sent by the web client are ignored. ::
marshalled, after setting the channel terminator to ``None`` to ensure that
any extraneous data sent by the web client are ignored. ::
class http_request_handler(asynchat.async_chat):
@ -281,4 +300,3 @@ extraneous data sent by the web client are ignored. ::
self.handling = True
self.ibuffer = []
self.handle_request()

View File

@ -3,7 +3,8 @@
===============================================
.. module:: asyncore
:synopsis: A base class for developing asynchronous socket handling services.
:synopsis: A base class for developing asynchronous socket handling
services.
.. moduleauthor:: Sam Rushing <rushing@nightmare.com>
.. sectionauthor:: Christopher Petrilli <petrilli@amber.org>
.. sectionauthor:: Steve Holden <sholden@holdenweb.com>
@ -16,76 +17,67 @@ service clients and servers.
There are only two ways to have a program on a single processor do "more than
one thing at a time." Multi-threaded programming is the simplest and most
popular way to do it, but there is another very different technique, that lets
popular way to do it, but there is another very different technique, that lets
you have nearly all the advantages of multi-threading, without actually using
multiple threads. It's really only practical if your program is largely I/O
bound. If your program is processor bound, then pre-emptive scheduled threads
are probably what you really need. Network servers are rarely processor bound,
however.
bound. If your program is processor bound, then pre-emptive scheduled threads
are probably what you really need. Network servers are rarely processor
bound, however.
If your operating system supports the :cfunc:`select` system call in its I/O
library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking place
in the "background." Although this strategy can seem strange and complex,
especially at first, it is in many ways easier to understand and control than
multi-threaded programming. The :mod:`asyncore` module solves many of the
difficult problems for you, making the task of building sophisticated
high-performance network servers and clients a snap. For "conversational"
applications and protocols the companion :mod:`asynchat` module is invaluable.
communication channels at once; doing other work while your I/O is taking
place in the "background." Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The :mod:`asyncore` module solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap. For
"conversational" applications and protocols the companion :mod:`asynchat`
module is invaluable.
The basic idea behind both modules is to create one or more network *channels*,
instances of class :class:`asyncore.dispatcher` and
:class:`asynchat.async_chat`. Creating the channels adds them to a global map,
used by the :func:`loop` function if you do not provide it with your own *map*.
The basic idea behind both modules is to create one or more network
*channels*, instances of class :class:`asyncore.dispatcher` and
:class:`asynchat.async_chat`. Creating the channels adds them to a global
map, used by the :func:`loop` function if you do not provide it with your own
*map*.
Once the initial channel(s) is(are) created, calling the :func:`loop` function
activates channel service, which continues until the last channel (including any
that have been added to the map during asynchronous service) is closed.
activates channel service, which continues until the last channel (including
any that have been added to the map during asynchronous service) is closed.
.. function:: loop([timeout[, use_poll[, map[,count]]]])
Enter a polling loop that terminates after count passes or all open channels
have been closed. All arguments are optional. The *count* parameter defaults
to None, resulting in the loop terminating only when all channels have been
closed. The *timeout* argument sets the timeout parameter for the appropriate
:func:`select` or :func:`poll` call, measured in seconds; the default is 30
seconds. The *use_poll* parameter, if true, indicates that :func:`poll` should
be used in preference to :func:`select` (the default is ``False``).
Enter a polling loop that terminates after count passes or all open
channels have been closed. All arguments are optional. The *count*
parameter defaults to None, resulting in the loop terminating only when all
channels have been closed. The *timeout* argument sets the timeout
parameter for the appropriate :func:`select` or :func:`poll` call, measured
in seconds; the default is 30 seconds. The *use_poll* parameter, if true,
indicates that :func:`poll` should be used in preference to :func:`select`
(the default is ``False``).
The *map* parameter is a dictionary whose items are the channels to watch. As
channels are closed they are deleted from their map. If *map* is omitted, a
global map is used. Channels (instances of :class:`asyncore.dispatcher`,
:class:`asynchat.async_chat` and subclasses thereof) can freely be mixed in the
map.
The *map* parameter is a dictionary whose items are the channels to watch.
As channels are closed they are deleted from their map. If *map* is
omitted, a global map is used. Channels (instances of
:class:`asyncore.dispatcher`, :class:`asynchat.async_chat` and subclasses
thereof) can freely be mixed in the map.
.. class:: dispatcher()
The :class:`dispatcher` class is a thin wrapper around a low-level socket
object. To make it more useful, it has a few methods for event-handling which
are called from the asynchronous loop. Otherwise, it can be treated as a
normal non-blocking socket object.
object. To make it more useful, it has a few methods for event-handling
which are called from the asynchronous loop. Otherwise, it can be treated
as a normal non-blocking socket object.
Two class attributes can be modified, to improve performance, or possibly even
to conserve memory.
.. data:: ac_in_buffer_size
The asynchronous input buffer size (default ``4096``).
.. data:: ac_out_buffer_size
The asynchronous output buffer size (default ``4096``).
The firing of low-level events at certain times or in certain connection states
tells the asynchronous loop that certain higher-level events have taken place.
For example, if we have asked for a socket to connect to another host, we know
that the connection has been made when the socket becomes writable for the first
time (at this point you know that you may write to it with the expectation of
success). The implied higher-level events are:
The firing of low-level events at certain times or in certain connection
states tells the asynchronous loop that certain higher-level events have
taken place. For example, if we have asked for a socket to connect to
another host, we know that the connection has been made when the socket
becomes writable for the first time (at this point you know that you may
write to it with the expectation of success). The implied higher-level
events are:
+----------------------+----------------------------------------+
| Event | Description |
@ -101,11 +93,11 @@ that have been added to the map during asynchronous service) is closed.
During asynchronous processing, each mapped channel's :meth:`readable` and
:meth:`writable` methods are used to determine whether the channel's socket
should be added to the list of channels :cfunc:`select`\ ed or :cfunc:`poll`\ ed
for read and write events.
should be added to the list of channels :cfunc:`select`\ ed or
:cfunc:`poll`\ ed for read and write events.
Thus, the set of channel events is larger than the basic socket events. The full
set of methods that can be overridden in your subclass follows:
Thus, the set of channel events is larger than the basic socket events. The
full set of methods that can be overridden in your subclass follows:
.. method:: dispatcher.handle_read()
@ -116,9 +108,9 @@ set of methods that can be overridden in your subclass follows:
.. method:: dispatcher.handle_write()
Called when the asynchronous loop detects that a writable socket can be written.
Often this method will implement the necessary buffering for performance. For
example::
Called when the asynchronous loop detects that a writable socket can be
written. Often this method will implement the necessary buffering for
performance. For example::
def handle_write(self):
sent = self.send(self.buffer)
@ -127,15 +119,15 @@ set of methods that can be overridden in your subclass follows:
.. method:: dispatcher.handle_expt()
Called when there is out of band (OOB) data for a socket connection. This will
almost never happen, as OOB is tenuously supported and rarely used.
Called when there is out of band (OOB) data for a socket connection. This
will almost never happen, as OOB is tenuously supported and rarely used.
.. method:: dispatcher.handle_connect()
Called when the active opener's socket actually makes a connection. Might send a
"welcome" banner, or initiate a protocol negotiation with the remote endpoint,
for example.
Called when the active opener's socket actually makes a connection. Might
send a "welcome" banner, or initiate a protocol negotiation with the remote
endpoint, for example.
.. method:: dispatcher.handle_close()
@ -152,40 +144,40 @@ set of methods that can be overridden in your subclass follows:
.. method:: dispatcher.handle_accept()
Called on listening channels (passive openers) when a connection can be
established with a new remote endpoint that has issued a :meth:`connect` call
for the local endpoint.
established with a new remote endpoint that has issued a :meth:`connect`
call for the local endpoint.
.. method:: dispatcher.readable()
Called each time around the asynchronous loop to determine whether a channel's
socket should be added to the list on which read events can occur. The default
method simply returns ``True``, indicating that by default, all channels will
be interested in read events.
Called each time around the asynchronous loop to determine whether a
channel's socket should be added to the list on which read events can
occur. The default method simply returns ``True``, indicating that by
default, all channels will be interested in read events.
.. method:: dispatcher.writable()
Called each time around the asynchronous loop to determine whether a channel's
socket should be added to the list on which write events can occur. The default
method simply returns ``True``, indicating that by default, all channels will
be interested in write events.
Called each time around the asynchronous loop to determine whether a
channel's socket should be added to the list on which write events can
occur. The default method simply returns ``True``, indicating that by
default, all channels will be interested in write events.
In addition, each channel delegates or extends many of the socket methods. Most
of these are nearly identical to their socket partners.
In addition, each channel delegates or extends many of the socket methods.
Most of these are nearly identical to their socket partners.
.. method:: dispatcher.create_socket(family, type)
This is identical to the creation of a normal socket, and will use the same
options for creation. Refer to the :mod:`socket` documentation for information
on creating sockets.
This is identical to the creation of a normal socket, and will use the same
options for creation. Refer to the :mod:`socket` documentation for
information on creating sockets.
.. method:: dispatcher.connect(address)
As with the normal socket object, *address* is a tuple with the first element
the host to connect to, and the second the port number.
As with the normal socket object, *address* is a tuple with the first
element the host to connect to, and the second the port number.
.. method:: dispatcher.send(data)
@ -195,38 +187,41 @@ of these are nearly identical to their socket partners.
.. method:: dispatcher.recv(buffer_size)
Read at most *buffer_size* bytes from the socket's remote end-point. An empty
string implies that the channel has been closed from the other end.
Read at most *buffer_size* bytes from the socket's remote end-point.
An empty string implies that the channel has been closed from the other
end.
.. method:: dispatcher.listen(backlog)
Listen for connections made to the socket. The *backlog* argument specifies the
maximum number of queued connections and should be at least 1; the maximum value
is system-dependent (usually 5).
Listen for connections made to the socket. The *backlog* argument
specifies the maximum number of queued connections and should be at least
1; the maximum value is system-dependent (usually 5).
.. method:: dispatcher.bind(address)
Bind the socket to *address*. The socket must not already be bound. (The
format of *address* depends on the address family --- see above.) To mark the
socket as re-usable (setting the :const:`SO_REUSEADDR` option), call the
:class:`dispatcher` object's :meth:`set_reuse_addr` method.
format of *address* depends on the address family --- see above.) To mark
the socket as re-usable (setting the :const:`SO_REUSEADDR` option), call
the :class:`dispatcher` object's :meth:`set_reuse_addr` method.
.. method:: dispatcher.accept()
Accept a connection. The socket must be bound to an address and listening for
connections. The return value is a pair ``(conn, address)`` where *conn* is a
*new* socket object usable to send and receive data on the connection, and
*address* is the address bound to the socket on the other end of the connection.
Accept a connection. The socket must be bound to an address and listening
for connections. The return value is a pair ``(conn, address)`` where
*conn* is a *new* socket object usable to send and receive data on the
connection, and *address* is the address bound to the socket on the other
end of the connection.
.. method:: dispatcher.close()
Close the socket. All future operations on the socket object will fail. The
remote end-point will receive no more data (after queued data is flushed).
Sockets are automatically closed when they are garbage-collected.
Close the socket. All future operations on the socket object will fail.
The remote end-point will receive no more data (after queued data is
flushed). Sockets are automatically closed when they are
garbage-collected.
.. _asyncore-example:
@ -266,4 +261,3 @@ implement its socket handling::
c = http_client('www.python.org', '/')
asyncore.loop()

View File

@ -9,8 +9,8 @@
The :mod:`autoGIL` module provides a function :func:`installAutoGIL` that
automatically locks and unlocks Python's Global Interpreter Lock when running an
event loop.
automatically locks and unlocks Python's :term:`Global Interpreter Lock` when
running an event loop.
.. exception:: AutoGILError

View File

@ -238,15 +238,15 @@ utility functions:
.. function:: iterencode(iterable, encoding[, errors])
Uses an incremental encoder to iteratively encode the input provided by
*iterable*. This function is a generator. *errors* (as well as any other keyword
argument) is passed through to the incremental encoder.
*iterable*. This function is a :term:`generator`. *errors* (as well as any
other keyword argument) is passed through to the incremental encoder.
.. function:: iterdecode(iterable, encoding[, errors])
Uses an incremental decoder to iteratively decode the input provided by
*iterable*. This function is a generator. *errors* (as well as any other keyword
argument) is passed through to the incremental decoder.
*iterable*. This function is a :term:`generator`. *errors* (as well as any
other keyword argument) is passed through to the incremental decoder.
The module also provides the following constants which are useful for reading
and writing to platform dependent files:

View File

@ -10,7 +10,7 @@
This module implements high-performance container datatypes. Currently,
there are two datatypes, :class:`deque` and :class:`defaultdict`, and
one datatype factory function, :func:`NamedTuple`. Python already
one datatype factory function, :func:`named_tuple`. Python already
includes built-in containers, :class:`dict`, :class:`list`,
:class:`set`, and :class:`tuple`. In addition, the optional :mod:`bsddb`
module has a :meth:`bsddb.btopen` method that can be used to create in-memory
@ -75,7 +75,7 @@ particular functionality, for example::
----------------------
.. class:: deque([iterable])
.. class:: deque([iterable[, maxlen]])
Returns a new deque object initialized left-to-right (using :meth:`append`) with
data from *iterable*. If *iterable* is not specified, the new deque is empty.
@ -91,6 +91,17 @@ particular functionality, for example::
position of the underlying data representation.
If *maxlen* is not specified or is *None*, deques may grow to an
arbitrary length. Otherwise, the deque is bounded to the specified maximum
length. Once a bounded length deque is full, when new items are added, a
corresponding number of items are discarded from the opposite end. Bounded
length deques provide functionality similar to the ``tail`` filter in
Unix. They are also useful for tracking transactions and other pools of data
where only the most recent activity is of interest.
.. versionchanged:: 2.6
Added *maxlen*
Deque objects support the following methods:
.. method:: deque.append(x)
@ -205,8 +216,8 @@ Example::
.. _deque-recipes:
Recipes
^^^^^^^
:class:`deque` Recipes
^^^^^^^^^^^^^^^^^^^^^^
This section shows various approaches to working with deques.
@ -223,42 +234,14 @@ To implement :class:`deque` slicing, use a similar approach applying
:meth:`rotate` to bring a target element to the left side of the deque. Remove
old entries with :meth:`popleft`, add new entries with :meth:`extend`, and then
reverse the rotation.
With minor variations on that approach, it is easy to implement Forth style
stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
``rot``, and ``roll``.
A roundrobin task server can be built from a :class:`deque` using
:meth:`popleft` to select the current task and :meth:`append` to add it back to
the tasklist if the input stream is not exhausted::
>>> def roundrobin(*iterables):
... pending = deque(iter(i) for i in iterables)
... while pending:
... task = pending.popleft()
... try:
... yield next(task)
... except StopIteration:
... continue
... pending.append(task)
...
>>> for value in roundrobin('abc', 'd', 'efgh'):
... print(value)
a
d
e
b
f
c
g
h
Multi-pass data reduction algorithms can be succinctly expressed and efficiently
coded by extracting elements with multiple calls to :meth:`popleft`, applying
the reduction function, and calling :meth:`append` to add the result back to the
queue.
a reduction function, and calling :meth:`append` to add the result back to the
deque.
For example, building a balanced binary tree of nested lists entails reducing
two adjacent nodes into one by grouping them in a list::
@ -273,7 +256,12 @@ two adjacent nodes into one by grouping them in a list::
>>> print(maketree('abcdefgh'))
[[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]]
Bounded length deques provide functionality similar to the ``tail`` filter
in Unix::
def tail(filename, n=10):
'Return the last n lines of a file'
return deque(open(filename), n)
.. _defaultdict-objects:
@ -395,14 +383,14 @@ Setting the :attr:`default_factory` to :class:`set` makes the
.. _named-tuple-factory:
:func:`NamedTuple` Factory Function for Tuples with Named Fields
----------------------------------------------------------------
:func:`named_tuple` Factory Function for Tuples with Named Fields
-----------------------------------------------------------------
Named tuples assign meaning to each position in a tuple and allow for more readable,
self-documenting code. They can be used wherever regular tuples are used, and
they add the ability to access fields by name instead of position index.
.. function:: NamedTuple(typename, fieldnames, [verbose])
.. function:: named_tuple(typename, fieldnames, [verbose])
Returns a new tuple subclass named *typename*. The new subclass is used to
create tuple-like objects that have fields accessable by attribute lookup as
@ -410,17 +398,24 @@ they add the ability to access fields by name instead of position index.
helpful docstring (with typename and fieldnames) and a helpful :meth:`__repr__`
method which lists the tuple contents in a ``name=value`` format.
The *fieldnames* are specified in a single string with each fieldname separated by
a space and/or comma. Any valid Python identifier may be used for a fieldname.
The *fieldnames* are a single string with each fieldname separated by whitespace
and/or commas (for example 'x y' or 'x, y'). Alternatively, the *fieldnames*
can be specified as a list of strings (such as ['x', 'y']).
Any valid Python identifier may be used for a fieldname except for names
starting and ending with double underscores. Valid identifiers consist of
letters, digits, and underscores but do not start with a digit and cannot be
a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, *print*,
or *raise*.
If *verbose* is true, will print the class definition.
*NamedTuple* instances do not have per-instance dictionaries, so they are
Named tuple instances do not have per-instance dictionaries, so they are
lightweight and require no more memory than regular tuples.
Example::
>>> Point = NamedTuple('Point', 'x y', True)
>>> Point = named_tuple('Point', 'x y', verbose=True)
class Point(tuple):
'Point(x, y)'
__slots__ = ()
@ -429,6 +424,9 @@ Example::
return tuple.__new__(cls, (x, y))
def __repr__(self):
return 'Point(x=%r, y=%r)' % self
def __asdict__(self):
'Return a new dict mapping field names to their values'
return dict(zip(('x', 'y'), self))
def __replace__(self, field, value):
'Return a new Point object replacing one field with a new value'
return Point(**dict(zip(('x', 'y'), self) + [(field, value)]))
@ -449,23 +447,46 @@ Example::
Named tuples are especially useful for assigning field names to result tuples returned
by the :mod:`csv` or :mod:`sqlite3` modules::
EmployeeRecord = named_tuple('EmployeeRecord', 'name, age, title, department, paygrade')
from itertools import starmap
import csv
EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade')
for record in starmap(EmployeeRecord, csv.reader(open("employees.csv", "rb"))):
print(emp.name, emp.title)
When casting a single record to a *NamedTuple*, use the star-operator [#]_ to unpack
import sqlite3
conn = sqlite3.connect('/companydata')
cursor = conn.cursor()
cursor.execute('SELECT name, age, title, department, paygrade FROM employees')
for emp in starmap(EmployeeRecord, cursor.fetchall()):
print emp.name, emp.title
When casting a single record to a named tuple, use the star-operator [#]_ to unpack
the values::
>>> t = [11, 22]
>>> Point(*t) # the star-operator unpacks any iterable object
Point(x=11, y=22)
In addition to the methods inherited from tuples, named tuples support
an additonal method and an informational read-only attribute.
When casting a dictionary to a named tuple, use the double-star-operator::
.. method:: somenamedtuple.replace(field, value)
>>> d = {'x': 11, 'y': 22}
>>> Point(**d)
Point(x=11, y=22)
In addition to the methods inherited from tuples, named tuples support
two additonal methods and a read-only attribute.
.. method:: somenamedtuple.__asdict__()
Return a new dict which maps field names to their corresponding values:
::
>>> p.__asdict__()
{'x': 11, 'y': 22}
.. method:: somenamedtuple.__replace__(field, value)
Return a new instance of the named tuple replacing the named *field* with a new *value*:
@ -480,20 +501,16 @@ an additonal method and an informational read-only attribute.
.. attribute:: somenamedtuple.__fields__
Return a tuple of strings listing the field names. This is useful for introspection,
for converting a named tuple instance to a dictionary, and for combining named tuple
types to create new named tuple types:
Return a tuple of strings listing the field names. This is useful for introspection
and for creating new named tuple types from existing named tuples.
::
>>> p.__fields__ # view the field names
>>> p.__fields__ # view the field names
('x', 'y')
>>> dict(zip(p.__fields__, p)) # convert to a dictionary
{'y': 22, 'x': 11}
>>> Color = NamedTuple('Color', 'red green blue')
>>> pixel_fields = ' '.join(Point.__fields__ + Color.__fields__) # combine fields
>>> Pixel = NamedTuple('Pixel', pixel_fields)
>>> Color = named_tuple('Color', 'red green blue')
>>> Pixel = named_tuple('Pixel', Point.__fields__ + Color.__fields__)
>>> Pixel(11, 22, 128, 255, 0)
Pixel(x=11, y=22, red=128, green=255, blue=0)'

View File

@ -37,9 +37,9 @@ Functions provided:
foo
</h1>
The function being decorated must return a generator-iterator when called. This
iterator must yield exactly one value, which will be bound to the targets in the
:keyword:`with` statement's :keyword:`as` clause, if any.
The function being decorated must return a :term:`generator`-iterator when
called. This iterator must yield exactly one value, which will be bound to
the targets in the :keyword:`with` statement's :keyword:`as` clause, if any.
At the point where the generator yields, the block nested in the :keyword:`with`
statement is executed. The generator is then resumed after the block is exited.

View File

@ -140,7 +140,7 @@ The following classes are provided:
CookieJar and FileCookieJar Objects
-----------------------------------
:class:`CookieJar` objects support the iterator protocol for iterating over
:class:`CookieJar` objects support the :term:`iterator` protocol for iterating over
contained :class:`Cookie` objects.
:class:`CookieJar` has the following methods:

View File

@ -60,7 +60,7 @@ The :mod:`csv` module defines the following functions:
.. function:: reader(csvfile[, dialect='excel'][, fmtparam])
Return a reader object which will iterate over lines in the given *csvfile*.
*csvfile* can be any object which supports the iterator protocol and returns a
*csvfile* can be any object which supports the :term:`iterator` protocol and returns a
string each time its :meth:`next` method is called --- file objects and list
objects are both suitable. If *csvfile* is a file object, it must be opened
with the 'b' flag on platforms where that makes a difference. An optional
@ -138,7 +138,7 @@ The :mod:`csv` module defines the following functions:
The :mod:`csv` module defines the following classes:
.. class:: DictReader(csvfile[, fieldnames=:const:None,[, restkey=:const:None[, restval=None[, dialect='excel'[, *args, **kwds]]]]])
.. class:: DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]])
Create an object which operates like a regular reader but maps the information
read into a dict whose keys are given by the optional *fieldnames* parameter.
@ -436,9 +436,9 @@ it is 8-bit-clean save for some problems with ASCII NUL characters. So you can
write functions or classes that handle the encoding and decoding for you as long
as you avoid encodings like UTF-16 that use NULs. UTF-8 is recommended.
:func:`unicode_csv_reader` below is a generator that wraps :class:`csv.reader`
:func:`unicode_csv_reader` below is a :term:`generator` that wraps :class:`csv.reader`
to handle Unicode CSV data (a list of Unicode strings). :func:`utf_8_encoder`
is a generator that encodes the Unicode strings as UTF-8, one string (or row) at
is a :term:`generator` that encodes the Unicode strings as UTF-8, one string (or row) at
a time. The encoded strings are parsed by the CSV reader, and
:func:`unicode_csv_reader` decodes the UTF-8-encoded cells back into Unicode::

View File

@ -584,8 +584,8 @@ Nested structures can also be initialized in the constructor in several ways::
>>> r = RECT(POINT(1, 2), POINT(3, 4))
>>> r = RECT((1, 2), (3, 4))
Fields descriptors can be retrieved from the *class*, they are useful for
debugging because they can provide useful information::
Field :term:`descriptor`\s can be retrieved from the *class*, they are useful
for debugging because they can provide useful information::
>>> print(POINT.x)
<Field type=c_long, ofs=0, size=4>
@ -1195,10 +1195,10 @@ Another example that may behave different from what one would expect is this::
>>>
Why is it printing ``False``? ctypes instances are objects containing a memory
block plus some descriptors accessing the contents of the memory. Storing a
Python object in the memory block does not store the object itself, instead the
``contents`` of the object is stored. Accessing the contents again constructs a
new Python each time!
block plus some :term:`descriptor`\s accessing the contents of the memory.
Storing a Python object in the memory block does not store the object itself,
instead the ``contents`` of the object is stored. Accessing the contents again
constructs a new Python object each time!
.. _ctypes-variable-sized-data-types:
@ -1366,8 +1366,8 @@ way is to instantiate one of the following classes:
:class:`WinDLL` and :class:`OleDLL` use the standard calling convention on this
platform.
The Python GIL is released before calling any function exported by these
libraries, and reacquired afterwards.
The Python :term:`global interpreter lock` is released before calling any
function exported by these libraries, and reacquired afterwards.
.. class:: PyDLL(name, mode=DEFAULT_MODE, handle=None)
@ -1948,7 +1948,7 @@ Data types
in case the memory block contains pointers.
Common methods of ctypes data types, these are all class methods (to be exact,
they are methods of the metaclass):
they are methods of the :term:`metaclass`):
.. method:: _CData.from_address(address)
@ -2263,7 +2263,7 @@ other data types containing pointer type fields.
Concrete structure and union types must be created by subclassing one of these
types, and at least define a :attr:`_fields_` class variable. ``ctypes`` will
create descriptors which allow reading and writing the fields by direct
create :term:`descriptor`\s which allow reading and writing the fields by direct
attribute accesses. These are the

View File

@ -174,7 +174,7 @@ floating point flying circus::
>>> c % a
Decimal("0.77")
And some mathematic functions are also available to Decimal::
And some mathematical functions are also available to Decimal::
>>> Decimal(2).sqrt()
Decimal("1.414213562373095048801688724")

View File

@ -10,6 +10,11 @@
.. % LaTeXification by Fred L. Drake, Jr. <fdrake@acm.org>.
This module provides classes and functions for comparing sequences. It
can be used for example, for comparing files, and can produce difference
information in various formats, including HTML and context and unified
diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
.. class:: SequenceMatcher
This is a flexible class for comparing pairs of sequences of any type, so long
@ -117,8 +122,8 @@
.. function:: context_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])
Compare *a* and *b* (lists of strings); return a delta (a generator generating
the delta lines) in context diff format.
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in context diff format.
Context diffs are a compact way of showing just the lines that have changed plus
a few lines of context. The changes are shown in a before/after style. The
@ -170,8 +175,8 @@
.. function:: ndiff(a, b[, linejunk][, charjunk])
Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style delta
(a generator generating the delta lines).
Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style
delta (a :term:`generator` generating the delta lines).
Optional keyword parameters *linejunk* and *charjunk* are for filter functions
(or ``None``):
@ -231,8 +236,8 @@
.. function:: unified_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])
Compare *a* and *b* (lists of strings); return a delta (a generator generating
the delta lines) in unified diff format.
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in unified diff format.
Unified diffs are a compact way of showing just the lines that have changed plus
a few lines of context. The changes are shown in a inline style (instead of
@ -423,7 +428,7 @@ use :meth:`set_seq2` to set the commonly used sequence once and call
.. method:: SequenceMatcher.get_grouped_opcodes([n])
Return a generator of groups with up to *n* lines of context.
Return a :term:`generator` of groups with up to *n* lines of context.
Starting with the groups returned by :meth:`get_opcodes`, this method splits out
smaller change clusters and eliminates intervening ranges which have no changes.

View File

@ -1,14 +1,14 @@
:mod:`dis` --- Disassembler for Python byte code
================================================
:mod:`dis` --- Disassembler for Python bytecode
===============================================
.. module:: dis
:synopsis: Disassembler for Python byte code.
:synopsis: Disassembler for Python bytecode.
The :mod:`dis` module supports the analysis of Python byte code by disassembling
The :mod:`dis` module supports the analysis of Python :term:`bytecode` by disassembling
it. Since there is no Python assembler, this module defines the Python assembly
language. The Python byte code which this module takes as an input is defined
language. The Python bytecode which this module takes as an input is defined
in the file :file:`Include/opcode.h` and used by the compiler and the
interpreter.
@ -35,7 +35,7 @@ The :mod:`dis` module defines the following functions and constants:
Disassemble the *bytesource* object. *bytesource* can denote either a module, a
class, a method, a function, or a code object. For a module, it disassembles
all functions. For a class, it disassembles all methods. For a single code
sequence, it prints one line per byte code instruction. If no object is
sequence, it prints one line per bytecode instruction. If no object is
provided, it disassembles the last traceback.
@ -70,12 +70,12 @@ The :mod:`dis` module defines the following functions and constants:
.. data:: opname
Sequence of operation names, indexable using the byte code.
Sequence of operation names, indexable using the bytecode.
.. data:: opmap
Dictionary mapping byte codes to operation names.
Dictionary mapping bytecodes to operation names.
.. data:: cmp_op
@ -85,45 +85,45 @@ The :mod:`dis` module defines the following functions and constants:
.. data:: hasconst
Sequence of byte codes that have a constant parameter.
Sequence of bytecodes that have a constant parameter.
.. data:: hasfree
Sequence of byte codes that access a free variable.
Sequence of bytecodes that access a free variable.
.. data:: hasname
Sequence of byte codes that access an attribute by name.
Sequence of bytecodes that access an attribute by name.
.. data:: hasjrel
Sequence of byte codes that have a relative jump target.
Sequence of bytecodes that have a relative jump target.
.. data:: hasjabs
Sequence of byte codes that have an absolute jump target.
Sequence of bytecodes that have an absolute jump target.
.. data:: haslocal
Sequence of byte codes that access a local variable.
Sequence of bytecodes that access a local variable.
.. data:: hascompare
Sequence of byte codes of Boolean operations.
Sequence of bytecodes of Boolean operations.
.. _bytecodes:
Python Byte Code Instructions
-----------------------------
Python Bytecode Instructions
----------------------------
The Python compiler currently generates the following byte code instructions.
The Python compiler currently generates the following bytecode instructions.
.. opcode:: STOP_CODE ()
@ -381,7 +381,7 @@ Miscellaneous opcodes.
.. opcode:: YIELD_VALUE ()
Pops ``TOS`` and yields it from a generator.
Pops ``TOS`` and yields it from a :term:`generator`.
.. opcode:: IMPORT_STAR ()
@ -416,9 +416,9 @@ Miscellaneous opcodes.
context manager's :meth:`__exit__` bound method. Below that are 1--3 values
indicating how/why the finally clause was entered:
* SECOND = None
* (SECOND, THIRD) = (WHY_{RETURN,CONTINUE}), retval
* SECOND = WHY_\*; no retval below it
* SECOND = ``None``
* (SECOND, THIRD) = (``WHY_{RETURN,CONTINUE}``), retval
* SECOND = ``WHY_*``; no retval below it
* (SECOND, THIRD, FOURTH) = exc_info()
In the last case, ``TOS(SECOND, THIRD, FOURTH)`` is called, otherwise
@ -428,6 +428,8 @@ Miscellaneous opcodes.
returns a 'true' value, this information is "zapped", to prevent ``END_FINALLY``
from re-raising the exception. (But non-local gotos should still be resumed.)
.. XXX explain the WHY stuff!
All of the following opcodes expect arguments. An argument is two bytes, with
the more significant byte last.
@ -548,32 +550,32 @@ the more significant byte last.
.. opcode:: JUMP_FORWARD (delta)
Increments byte code counter by *delta*.
Increments bytecode counter by *delta*.
.. opcode:: JUMP_IF_TRUE (delta)
If TOS is true, increment the byte code counter by *delta*. TOS is left on the
If TOS is true, increment the bytecode counter by *delta*. TOS is left on the
stack.
.. opcode:: JUMP_IF_FALSE (delta)
If TOS is false, increment the byte code counter by *delta*. TOS is not
If TOS is false, increment the bytecode counter by *delta*. TOS is not
changed.
.. opcode:: JUMP_ABSOLUTE (target)
Set byte code counter to *target*.
Set bytecode counter to *target*.
.. opcode:: FOR_ITER (delta)
``TOS`` is an iterator. Call its :meth:`__next__` method. If this yields a new
value, push it on the stack (leaving the iterator below it). If the iterator
indicates it is exhausted ``TOS`` is popped, and the byte code counter is
incremented by *delta*.
``TOS`` is an :term:`iterator`. Call its :meth:`__next__` method. If this
yields a new value, push it on the stack (leaving the iterator below it). If
the iterator indicates it is exhausted ``TOS`` is popped, and the byte code
counter is incremented by *delta*.
.. % \begin{opcodedesc}{FOR_LOOP}{delta}
.. % This opcode is obsolete.

View File

@ -135,7 +135,7 @@ The following exceptions are the exceptions that are actually raised.
.. exception:: GeneratorExit
Raise when a generator's :meth:`close` method is called.
Raise when a :term:`generator`\'s :meth:`close` method is called.
.. exception:: IOError
@ -241,8 +241,8 @@ The following exceptions are the exceptions that are actually raised.
.. exception:: StopIteration
Raised by builtin :func:`next` and an iterator's :meth:`__next__` method to
signal that there are no further values.
Raised by builtin :func:`next` and an :term:`iterator`\'s :meth:`__next__`
method to signal that there are no further values.
.. exception:: SyntaxError

View File

@ -8,7 +8,8 @@
The :mod:`filecmp` module defines functions to compare files and directories,
with various optional time/correctness trade-offs.
with various optional time/correctness trade-offs. For comparing files,
see also the :mod:`difflib` module.
The :mod:`filecmp` module defines the following functions:

View File

@ -41,7 +41,7 @@ available. They are listed here in alphabetical order.
top-level package (the name up till the first dot) is returned, *not* the
module named by *name*. However, when a non-empty *fromlist* argument is
given, the module named by *name* is returned. This is done for
compatibility with the bytecode generated for the different kinds of import
compatibility with the :term:`bytecode` generated for the different kinds of import
statement; when using ``import spam.ham.eggs``, the top-level package
:mod:`spam` must be placed in the importing namespace, but when using ``from
spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the
@ -317,7 +317,7 @@ available. They are listed here in alphabetical order.
.. function:: enumerate(iterable)
Return an enumerate object. *iterable* must be a sequence, an iterator, or some
Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some
other object which supports iteration. The :meth:`__next__` method of the
iterator returned by :func:`enumerate` returns a tuple containing a count (from
zero) and the corresponding value obtained from iterating over *iterable*.
@ -340,7 +340,7 @@ available. They are listed here in alphabetical order.
The *expression* argument is parsed and evaluated as a Python expression
(technically speaking, a condition list) using the *globals* and *locals*
dictionaries as global and local name space. If the *globals* dictionary is
dictionaries as global and local namespace. If the *globals* dictionary is
present and lacks '__builtins__', the current globals are copied into *globals*
before *expression* is parsed. This means that *expression* normally has full
access to the standard :mod:`__builtin__` module and restricted environments are
@ -408,10 +408,9 @@ available. They are listed here in alphabetical order.
Construct an iterator from those elements of *iterable* for which *function*
returns true. *iterable* may be either a sequence, a container which
supports iteration, or an iterator, If *iterable* is a string or a tuple, the
result also has that type; otherwise it is always a list. If *function* is
``None``, the identity function is assumed, that is, all elements of
*iterable* that are false are removed.
supports iteration, or an iterator. If *function* is ``None``, the identity
function is assumed, that is, all elements of *iterable* that are false are
removed.
Note that ``filter(function, iterable)`` is equivalent to the generator
expression ``(item for item in iterable if function(item))`` if function is
@ -543,15 +542,15 @@ available. They are listed here in alphabetical order.
.. function:: int([x[, radix]])
Convert a string or number to an integer. If the argument is a string, it
must contain a possibly signed number of arbitrary size,
possibly embedded in whitespace. The *radix* parameter gives the base for the
conversion and may be any integer in the range [2, 36], or zero. If *radix* is
zero, the interpretation is the same as for integer literals. If *radix* is
specified and *x* is not a string, :exc:`TypeError` is raised. Otherwise, the
argument may be another integer, a floating point number or any other object
that has an :meth:`__int__` method. Conversion
of floating point numbers to integers truncates (towards zero). If no
arguments are given, returns ``0``.
must contain a possibly signed number of arbitrary size, possibly embedded in
whitespace. The *radix* parameter gives the base for the conversion (which
is 10 by default) and may be any integer in the range [2, 36], or zero. If
*radix* is zero, the interpretation is the same as for integer literals. If
*radix* is specified and *x* is not a string, :exc:`TypeError` is raised.
Otherwise, the argument may be another integer, a floating point number or
any other object that has an :meth:`__int__` method. Conversion of floating
point numbers to integers truncates (towards zero). If no arguments are
given, returns ``0``.
The integer type is described in :ref:`typesnumeric`.
@ -577,7 +576,7 @@ available. They are listed here in alphabetical order.
.. function:: iter(o[, sentinel])
Return an iterator object. The first argument is interpreted very differently
Return an :term:`iterator` object. The first argument is interpreted very differently
depending on the presence of the second argument. Without a second argument, *o*
must be a collection object which supports the iteration protocol (the
:meth:`__iter__` method), or it must support the sequence protocol (the
@ -857,9 +856,9 @@ available. They are listed here in alphabetical order.
.. function:: reversed(seq)
Return a reverse iterator. *seq* must be an object which supports the sequence
protocol (the :meth:`__len__` method and the :meth:`__getitem__` method with
integer arguments starting at ``0``).
Return a reverse :term:`iterator`. *seq* must be an object which supports
the sequence protocol (the :meth:`__len__` method and the :meth:`__getitem__`
method with integer arguments starting at ``0``).
.. function:: round(x[, n])

View File

@ -28,8 +28,8 @@ subshell. (For tilde and shell variable expansion, use
.. function:: iglob(pathname)
Return an iterator which yields the same values as :func:`glob` without actually
storing them all simultaneously.
Return an :term:`iterator` which yields the same values as :func:`glob`
without actually storing them all simultaneously.
For example, consider a directory containing only the following files:

View File

@ -90,8 +90,8 @@ The module also offers three general purpose functions based on heaps.
.. function:: merge(*iterables)
Merge multiple sorted inputs into a single sorted output (for example, merge
timestamped entries from multiple log files). Returns an iterator over over the
sorted values.
timestamped entries from multiple log files). Returns an :term:`iterator`
over over the sorted values.
Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, does
not pull the data into memory all at once, and assumes that each of the input

View File

@ -67,7 +67,7 @@ attributes:
+-----------+-----------------+---------------------------+
| | __code__ | code object containing |
| | | compiled function |
| | | bytecode |
| | | :term:`bytecode` |
+-----------+-----------------+---------------------------+
| | __defaults__ | tuple of any default |
| | | values for arguments |
@ -253,30 +253,31 @@ attributes:
.. function:: ismethoddescriptor(object)
Return true if the object is a method descriptor, but not if ismethod() or
isclass() or isfunction() are true.
Return true if the object is a method descriptor, but not if :func:`ismethod`
or :func:`isclass` or :func:`isfunction` are true.
This is new as of Python 2.2, and, for example, is true of int.__add__. An
object passing this test has a __get__ attribute but not a __set__ attribute,
but beyond that the set of attributes varies. __name__ is usually sensible, and
__doc__ often is.
This is new as of Python 2.2, and, for example, is true of
``int.__add__``. An object passing this test has a :attr:`__get__` attribute
but not a :attr:`__set__` attribute, but beyond that the set of attributes
varies. :attr:`__name__` is usually sensible, and :attr:`__doc__` often is.
Methods implemented via descriptors that also pass one of the other tests return
false from the ismethoddescriptor() test, simply because the other tests promise
more -- you can, e.g., count on having the im_func attribute (etc) when an
object passes ismethod().
Methods implemented via descriptors that also pass one of the other tests
return false from the :func:`ismethoddescriptor` test, simply because the
other tests promise more -- you can, e.g., count on having the
:attr:`im_func` attribute (etc) when an object passes :func:`ismethod`.
.. function:: isdatadescriptor(object)
Return true if the object is a data descriptor.
Data descriptors have both a __get__ and a __set__ attribute. Examples are
properties (defined in Python), getsets, and members. The latter two are
defined in C and there are more specific tests available for those types, which
is robust across Python implementations. Typically, data descriptors will also
have __name__ and __doc__ attributes (properties, getsets, and members have both
of these attributes), but this is not guaranteed.
Data descriptors have both a :attr:`__get__` and a :attr:`__set__` attribute.
Examples are properties (defined in Python), getsets, and members. The
latter two are defined in C and there are more specific tests available for
those types, which is robust across Python implementations. Typically, data
descriptors will also have :attr:`__name__` and :attr:`__doc__` attributes
(properties, getsets, and members have both of these attributes), but this is
not guaranteed.
.. function:: isgetsetdescriptor(object)
@ -293,8 +294,8 @@ attributes:
Return true if the object is a member descriptor.
Member descriptors are attributes defined in extension modules via
``PyMemberDef`` structures. For Python implementations without such types, this
method will always return ``False``.
``PyMemberDef`` structures. For Python implementations without such types,
this method will always return ``False``.
.. _inspect-source:

View File

@ -8,7 +8,7 @@
.. sectionauthor:: Raymond Hettinger <python@rcn.com>
This module implements a number of iterator building blocks inspired by
This module implements a number of :term:`iterator` building blocks inspired by
constructs from the Haskell and SML programming languages. Each has been recast
in a form suitable for Python.
@ -77,19 +77,15 @@ loops that truncate the stream.
.. function:: count([n])
Make an iterator that returns consecutive integers starting with *n*. If not
specified *n* defaults to zero. Does not currently support python long
integers. Often used as an argument to :func:`imap` to generate consecutive
data points. Also, used with :func:`izip` to add sequence numbers. Equivalent
to::
specified *n* defaults to zero. Often used as an argument to :func:`imap` to
generate consecutive data points. Also, used with :func:`izip` to add sequence
numbers. Equivalent to::
def count(n=0):
while True:
yield n
n += 1
Note, :func:`count` does not check for overflow and will return negative numbers
after exceeding ``sys.maxint``. This behavior may change in the future.
.. function:: cycle(iterable)
@ -451,8 +447,8 @@ The superior memory performance is kept by processing elements one at a time
rather than bringing the whole iterable into memory all at once. Code volume is
kept small by linking the tools together in a functional style which helps
eliminate temporary variables. High speed is retained by preferring
"vectorized" building blocks over the use of for-loops and generators which
incur interpreter overhead. ::
"vectorized" building blocks over the use of for-loops and :term:`generator`\s
which incur interpreter overhead. ::
def take(n, seq):
return list(islice(seq, n))

View File

@ -20,7 +20,7 @@ logging system for applications.
Logging is performed by calling methods on instances of the :class:`Logger`
class (hereafter called :dfn:`loggers`). Each instance has a name, and they are
conceptually arranged in a name space hierarchy using dots (periods) as
conceptually arranged in a namespace hierarchy using dots (periods) as
separators. For example, a logger named "scan" is the parent of loggers
"scan.text", "scan.html" and "scan.pdf". Logger names can be anything you want,
and indicate the area of an application in which a logged message originates.
@ -430,7 +430,7 @@ instantiated directly, but always through the module-level function
FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
logging.basicConfig(format=FORMAT)
dict = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' }
d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' }
logger = logging.getLogger("tcpserver")
logger.warning("Protocol problem: %s", "connection reset", extra=d)

View File

@ -805,7 +805,7 @@ follows:
A message is typically moved from :file:`new` to :file:`cur` after its mailbox
has been accessed, whether or not the message is has been read. A message
``msg`` has been read if ``"S" not in msg.get_flags()`` is ``True``.
``msg`` has been read if ``"S" in msg.get_flags()`` is ``True``.
.. method:: MaildirMessage.set_subdir(subdir)

View File

@ -25,7 +25,9 @@ transfer of Python objects through RPC calls, see the modules :mod:`pickle` and
writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files.
Therefore, the Python maintainers reserve the right to modify the marshal format
in backward incompatible ways should the need arise. If you're serializing and
de-serializing Python objects, use the :mod:`pickle` module instead.
de-serializing Python objects, use the :mod:`pickle` module instead -- the
performance is comparable, version independence is guaranteed, and pickle
supports a substantially wider range of objects than marshal.
.. warning::
@ -36,12 +38,18 @@ de-serializing Python objects, use the :mod:`pickle` module instead.
Not all Python object types are supported; in general, only objects whose value
is independent from a particular invocation of Python can be written and read by
this module. The following types are supported: ``None``, integers, long
integers, floating point numbers, strings, Unicode objects, tuples, lists,
integers, floating point numbers, strings, Unicode objects, tuples, lists, sets,
dictionaries, and code objects, where it should be understood that tuples, lists
and dictionaries are only supported as long as the values contained therein are
themselves supported; and recursive lists and dictionaries should not be written
(they will cause infinite loops).
.. warning::
Some unsupported types such as subclasses of builtins will appear to marshal
and unmarshal correctly, but in fact, their type will change and the
additional subclass functionality and instance attributes will be lost.
.. warning::
On machines where C's ``long int`` type has more than 32 bits (such as the

View File

@ -38,7 +38,7 @@ not update the underlying file.
To map anonymous memory, -1 should be passed as the fileno along with the length.
.. function:: mmap(fileno, length[, tagname[, access]])
.. function:: mmap(fileno, length[, tagname[, access[, offset]]])
**(Windows version)** Maps *length* bytes from the file specified by the file
handle *fileno*, and returns a mmap object. If *length* is larger than the
@ -54,8 +54,12 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
the mapping is created without a name. Avoiding the use of the tag parameter
will assist in keeping your code portable between Unix and Windows.
*offset* may be specified as a non-negative integer offset. mmap references will
be relative to the offset from the beginning of the file. *offset* defaults to 0.
*offset* must be a multiple of the ALLOCATIONGRANULARITY.
.. function:: mmap(fileno, length[, flags[, prot[, access]]])
.. function:: mmap(fileno, length[, flags[, prot[, access[, offset]]]])
:noindex:
**(Unix version)** Maps *length* bytes from the file specified by the file
@ -77,6 +81,10 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
parameter. It is an error to specify both *flags*, *prot* and *access*. See
the description of *access* above for information on how to use this parameter.
*offset* may be specified as a non-negative integer offset. mmap references 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.
Memory-mapped file objects support the following methods:
@ -169,3 +177,4 @@ Memory-mapped file objects support the following methods:
created with :const:`ACCESS_READ`, then writing to it will throw a
:exc:`TypeError` exception.

View File

@ -950,7 +950,7 @@ must specify for any option using that action.
* ``append_const`` [required: ``const``; relevant: :attr:`dest`]
Like ``store_const``, but the value ``const`` is appended to :attr:`dest`; as
with ``append``, :attr:`dest` defaults to ``None``, and an an empty list is
with ``append``, :attr:`dest` defaults to ``None``, and an empty list is
automatically created the first time the option is encountered.
* ``count`` [relevant: :attr:`dest`]
@ -1116,7 +1116,7 @@ Integer arguments (type ``int`` or ``long``) are parsed as follows:
* if the number starts with ``0``, it is parsed as an octal number
* if the number starts with ``0b``, is is parsed as a binary number
* if the number starts with ``0b``, it is parsed as a binary number
* otherwise, the number is parsed as a decimal number

View File

@ -279,8 +279,8 @@ write files see :func:`open`, and for accessing the filesystem see the
.. note::
The newer :func:`os.walk` generator supplies similar functionality and can be
easier to use.
The newer :func:`os.walk` :term:`generator` supplies similar functionality
and can be easier to use.
.. data:: supports_unicode_filenames

View File

@ -107,9 +107,14 @@ process and user.
passed to the appropriate process-creation functions to cause child processes
to use a modified environment.
If the platform supports the :func:`unsetenv` function, you can delete items in
If the platform supports the :func:`unsetenv` function, you can delete items in
this mapping to unset environment variables. :func:`unsetenv` will be called
automatically when an item is deleted from ``os.environ``.
automatically when an item is deleted from ``os.environ``, and when
one of the :meth:`pop` or :meth:`clear` methods is called.
.. versionchanged:: 2.6
Also unset environment variables when calling :meth:`os.environ.clear`
and :meth:`os.environ.pop`.
.. function:: chdir(path)
@ -541,7 +546,7 @@ by file descriptors.
.. function:: ttyname(fd)
Return a string which specifies the terminal device associated with
file-descriptor *fd*. If *fd* is not associated with a terminal device, an
file descriptor *fd*. If *fd* is not associated with a terminal device, an
exception is raised. Availability:Macintosh, Unix.

View File

@ -321,7 +321,7 @@ Examples
.. index:: builtin: compile
The parser modules allows operations to be performed on the parse tree of Python
source code before the bytecode is generated, and provides for inspection of the
source code before the :term:`bytecode` is generated, and provides for inspection of the
parse tree for information gathering purposes. Two examples are presented. The
simple example demonstrates emulation of the :func:`compile` built-in function
and the complex example shows the use of a parse tree for information discovery.

View File

@ -239,7 +239,7 @@ commands [*bpnumber*]
Specifying any command resuming execution (currently continue, step, next,
return, jump, quit and their abbreviations) terminates the command list (as if
that command was immediately followed by end). This is because any time you
resume execution (even with a simple next or step), you may encounter· another
resume execution (even with a simple next or step), you may encounter another
breakpoint--which could have its own command list, leading to ambiguities about
which list to execute.
@ -323,7 +323,7 @@ unalias *name*
(Pdb)
run [*args* ...]
Restart the debugged python program. If an argument is supplied, it is splitted
Restart the debugged python program. If an argument is supplied, it is split
with "shlex" and the result is used as the new sys.argv. History, breakpoints,
actions and debugger options are preserved. "restart" is an alias for "run".

View File

@ -122,7 +122,7 @@ There are currently 3 different protocols which can be used for pickling.
earlier versions of Python.
* Protocol version 2 was introduced in Python 2.3. It provides much more
efficient pickling of new-style classes.
efficient pickling of :term:`new-style class`\es.
Refer to :pep:`307` for more information.
@ -418,8 +418,8 @@ New-style types can provide a :meth:`__getnewargs__` method that is used for
protocol 2. Implementing this method is needed if the type establishes some
internal invariants when the instance is created, or if the memory allocation is
affected by the values passed to the :meth:`__new__` method for the type (as it
is for tuples and strings). Instances of a new-style type :class:`C` are
created using ::
is for tuples and strings). Instances of a :term:`new-style class` :class:`C`
are created using ::
obj = C.__new__(C, *args)
@ -447,8 +447,8 @@ can do what they want. [#]_
.. warning::
For new-style classes, if :meth:`__getstate__` returns a false value, the
:meth:`__setstate__` method will not be called.
For :term:`new-style class`\es, if :meth:`__getstate__` returns a false
value, the :meth:`__setstate__` method will not be called.
Pickling and unpickling extension types

View File

@ -27,9 +27,9 @@ probably won't find the :mod:`pickletools` module relevant.
.. function:: genops(pickle)
Provides an iterator over all of the opcodes in a pickle, returning a sequence
of ``(opcode, arg, pos)`` triples. *opcode* is an instance of an
:class:`OpcodeInfo` class; *arg* is the decoded value, as a Python object, of
the opcode's argument; *pos* is the position at which this opcode is located.
Provides an :term:`iterator` over all of the opcodes in a pickle, returning a
sequence of ``(opcode, arg, pos)`` triples. *opcode* is an instance of an
:class:`OpcodeInfo` class; *arg* is the decoded value, as a Python object, of
the opcode's argument; *pos* is the position at which this opcode is located.
*pickle* can be a string or a file-like object.

View File

@ -43,6 +43,6 @@ The :mod:`pty` module defines the following functions:
reading from the controlling terminal.
The functions *master_read* and *stdin_read* should be functions which read from
a file-descriptor. The defaults try to read 1024 bytes each time they are
a file descriptor. The defaults try to read 1024 bytes each time they are
called.

View File

@ -19,10 +19,10 @@ in Python, including many standard and optional extension modules.
.. function:: readmodule(module[, path])
Read a module and return a dictionary mapping class names to class descriptor
objects. The parameter *module* should be the name of a module as a string; it
may be the name of a module within a package. The *path* parameter should be a
sequence, and is used to augment the value of ``sys.path``, which is used to
locate module source code.
objects. The parameter *module* should be the name of a module as a string;
it may be the name of a module within a package. The *path* parameter should
be a sequence, and is used to augment the value of ``sys.path``, which is
used to locate module source code.
.. % The 'inpackage' parameter appears to be for internal use only....

View File

@ -28,14 +28,14 @@ The solution is to use Python's raw string notation for regular expression
patterns; backslashes are not handled in any special way in a string literal
prefixed with ``'r'``. So ``r"\n"`` is a two-character string containing
``'\'`` and ``'n'``, while ``"\n"`` is a one-character string containing a
newline. Usually patterns will be expressed in Python code using this raw string
notation.
newline. Usually patterns will be expressed in Python code using this raw
string notation.
.. seealso::
Mastering Regular Expressions
Book on regular expressions by Jeffrey Friedl, published by O'Reilly. The
second edition of the book no longer covers Python at all, but the first
second edition of the book no longer covers Python at all, but the first
edition covered writing good regular expression patterns in great detail.
@ -427,8 +427,8 @@ form.
.. function:: compile(pattern[, flags])
Compile a regular expression pattern into a regular expression object, which can
be used for matching using its :func:`match` and :func:`search` methods,
Compile a regular expression pattern into a regular expression object, which
can be used for matching using its :func:`match` and :func:`search` methods,
described below.
The expression's behaviour can be modified by specifying a *flags* value.
@ -444,8 +444,8 @@ form.
result = re.match(pat, str)
but the version using :func:`compile` is more efficient when the expression will
be used several times in a single program.
but the version using :func:`compile` is more efficient when the expression
will be used several times in a single program.
.. % (The compiled version of the last pattern passed to
.. % \function{re.match()} or \function{re.search()} is cached, so
@ -463,8 +463,8 @@ form.
.. data:: L
LOCALE
Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` dependent on the current
locale.
Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` dependent on the
current locale.
.. data:: M
@ -556,17 +556,18 @@ form.
.. function:: findall(pattern, string[, flags])
Return a list of all non-overlapping matches of *pattern* in *string*. If one
or more groups are present in the pattern, return a list of groups; this will be
a list of tuples if the pattern has more than one group. Empty matches are
included in the result unless they touch the beginning of another match.
Return all non-overlapping matches of *pattern* in *string*, as a list of
strings. If one or more groups are present in the pattern, return a list of
groups; this will be a list of tuples if the pattern has more than one group.
Empty matches are included in the result unless they touch the beginning of
another match.
.. function:: finditer(pattern, string[, flags])
Return an iterator over all non-overlapping matches for the RE *pattern* in
*string*. For each match, the iterator returns a match object. Empty matches
are included in the result unless they touch the beginning of another match.
Return an :term:`iterator` yielding :class:`MatchObject` instances over all
non-overlapping matches for the RE *pattern* in *string*. Empty matches are
included in the result unless they touch the beginning of another match.
.. function:: sub(pattern, repl, string[, count])
@ -729,7 +730,9 @@ attributes:
Match Objects
-------------
:class:`MatchObject` instances support the following methods and attributes:
Match objects always have a boolean value of :const:`True`, so that you can test
whether e.g. :func:`match` resulted in a match with a simple if statement. They
support the following methods and attributes:
.. method:: MatchObject.expand(template)

View File

@ -69,10 +69,10 @@ may use a different placeholder, such as ``%s`` or ``:1``.) For example::
):
c.execute('insert into stocks values (?,?,?,?,?)', t)
To retrieve data after executing a SELECT statement, you can either treat the
cursor as an iterator, call the cursor's :meth:`fetchone` method to retrieve a
single matching row, or call :meth:`fetchall` to get a list of the matching
rows.
To retrieve data after executing a SELECT statement, you can either treat the
cursor as an :term:`iterator`, call the cursor's :meth:`fetchone` method to
retrieve a single matching row, or call :meth:`fetchall` to get a list of the
matching rows.
This example uses the iterator form::
@ -408,13 +408,13 @@ A :class:`Cursor` instance has the following attributes and methods:
.. method:: Cursor.executemany(sql, seq_of_parameters)
Executes a SQL command against all parameter sequences or mappings found in the
sequence *sql*. The :mod:`sqlite3` module also allows using an iterator yielding
parameters instead of a sequence.
Executes a SQL command against all parameter sequences or mappings found in
the sequence *sql*. The :mod:`sqlite3` module also allows using an
:term:`iterator` yielding parameters instead of a sequence.
.. literalinclude:: ../includes/sqlite3/executemany_1.py
Here's a shorter example using a generator:
Here's a shorter example using a :term:`generator`:
.. literalinclude:: ../includes/sqlite3/executemany_2.py

View File

@ -223,7 +223,7 @@ Functions, Constants, and Exceptions
.. data:: PROTOCOL_TLSv1
Selects SSL version 2 as the channel encryption protocol. This is
Selects TLS version 1 as the channel encryption protocol. This is
the most modern version, and probably the best choice for maximum
protection, if both sides can speak it.

View File

@ -449,10 +449,10 @@ Once an iterator's :meth:`__next__` method raises :exc:`StopIteration`, it must
continue to do so on subsequent calls. Implementations that do not obey this
property are deemed broken.
Python's generators provide a convenient way to implement the iterator protocol.
If a container object's :meth:`__iter__` method is implemented as a generator,
it will automatically return an iterator object (technically, a generator
object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
Python's :term:`generator`\s provide a convenient way to implement the iterator
protocol. If a container object's :meth:`__iter__` method is implemented as a
generator, it will automatically return an iterator object (technically, a
generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
.. _typesseq:
@ -655,9 +655,9 @@ functions based on regular expressions.
.. method:: str.count(sub[, start[, end]])
Return the number of occurrences of substring *sub* in string S\
``[start:end]``. Optional arguments *start* and *end* are interpreted as in
slice notation.
Return the number of occurrences of substring *sub* in the range [*start*,
*end*]. Optional arguments *start* and *end* are interpreted as in slice
notation.
.. method:: str.encode([encoding[, errors]])
@ -682,8 +682,11 @@ functions based on regular expressions.
.. method:: str.expandtabs([tabsize])
Return a copy of the string where all tab characters are expanded using spaces.
If *tabsize* is not given, a tab size of ``8`` characters is assumed.
Return a copy of the string where all tab characters are replaced by one or
more spaces, depending on the current column and the given tab size. The
column number is reset to zero after each newline occurring in the string.
If *tabsize* is not given, a tab size of ``8`` characters is assumed. This
doesn't understand other non-printing characters or escape sequences.
.. method:: str.find(sub[, start[, end]])
@ -869,19 +872,23 @@ functions based on regular expressions.
string. If *maxsplit* is given, at most *maxsplit* splits are done (thus,
the list will have at most ``maxsplit+1`` elements). If *maxsplit* is not
specified, then there is no limit on the number of splits (all possible
splits are made). Consecutive delimiters are not grouped together and are
splits are made).
If *sep is given, consecutive delimiters are not grouped together and are
deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns
``['1', '', '2']``). The *sep* argument may consist of multiple characters
(for example, ``'1, 2, 3'.split(', ')`` returns ``['1', '2', '3']``).
(for example, ``'1<>2<>3'.split('<>')`` returns ``['1', '2', '3']``).
Splitting an empty string with a specified separator returns ``['']``.
If *sep* is not specified or is ``None``, a different splitting algorithm is
applied. First, whitespace characters (spaces, tabs, newlines, returns, and
formfeeds) are stripped from both ends. Then, words are separated by arbitrary
length strings of whitespace characters. Consecutive whitespace delimiters are
treated as a single delimiter (``'1 2 3'.split()`` returns ``['1', '2',
'3']``). Splitting an empty string or a string consisting of just whitespace
returns an empty list.
applied: runs of consecutive whitespace are regarded as a single separator,
and the result will contain no empty strings at the start or end if the
string has leading or trailing whitespace. Consequently, splitting an empty
string or a string consisting of just whitespace with a ``None`` separator
returns ``[]``.
For example, ``' 1 2 3 '.split()`` returns ``['1', '2', '3']``, and
``' 1 2 3 '.split(None, 1)`` returns ``['1', '2 3 ']``.
.. method:: str.splitlines([keepends])
@ -947,8 +954,10 @@ functions based on regular expressions.
.. method:: str.zfill(width)
Return the numeric string left filled with zeros in a string of length *width*.
The original string is returned if *width* is less than ``len(s)``.
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)``.
.. _old-string-formatting:
@ -1865,8 +1874,7 @@ Files have the following methods:
.. method:: file.fileno()
.. index::
single: file descriptor
single: descriptor, file
pair: file; descriptor
module: fcntl
Return the integer "file descriptor" that is used by the underlying
@ -2091,7 +2099,7 @@ to be provided for a context manager object to define a runtime context:
.. method:: contextmanager.__exit__(exc_type, exc_val, exc_tb)
Exit the runtime context and return a Boolean flag indicating if any expection
Exit the runtime context and return a Boolean flag indicating if any exception
that occurred should be suppressed. If an exception occurred while executing the
body of the :keyword:`with` statement, the arguments contain the exception type,
value and traceback information. Otherwise, all three arguments are ``None``.
@ -2115,7 +2123,7 @@ decimal arithmetic context. The specific types are not treated specially beyond
their implementation of the context management protocol. See the
:mod:`contextlib` module for some examples.
Python's generators and the ``contextlib.contextfactory`` decorator provide a
Python's :term:`generator`\s and the ``contextlib.contextfactory`` decorator provide a
convenient way to implement these protocols. If a generator function is
decorated with the ``contextlib.contextfactory`` decorator, it will return a
context manager implementing the necessary :meth:`__enter__` and

View File

@ -13,7 +13,7 @@ implemented in Python. The scanner in this module returns comments as tokens as
well, making it useful for implementing "pretty-printers," including colorizers
for on-screen displays.
The primary entry point is a generator:
The primary entry point is a :term:`generator`:
.. function:: generate_tokens(readline)

View File

@ -113,8 +113,8 @@ The module defines the following names:
.. data:: GeneratorType
The type of generator-iterator objects, produced by calling a generator
function.
The type of :term:`generator`-iterator objects, produced by calling a
generator function.
.. data:: CodeType

View File

@ -29,7 +29,7 @@ It defines the following public functions:
:exc:`IOError` exception is raised. If all went well, a file-like object is
returned. This supports the following methods: :meth:`read`, :meth:`readline`,
:meth:`readlines`, :meth:`fileno`, :meth:`close`, :meth:`info` and
:meth:`geturl`. It also has proper support for the iterator protocol. One
:meth:`geturl`. It also has proper support for the :term:`iterator` protocol. One
caveat: the :meth:`read` method, if the size argument is omitted or negative,
may not read until the end of the data stream; there is no good way to determine
that the entire stream from a socket has been read in the general case.

View File

@ -51,9 +51,9 @@ is exposed by the :mod:`weakref` module for the benefit of advanced uses.
Not all objects can be weakly referenced; those objects which can include class
instances, functions written in Python (but not in C), methods (both bound and
unbound), sets, frozensets, file objects, generators, type objects, DBcursor
objects from the :mod:`bsddb` module, sockets, arrays, deques, and regular
expression pattern objects.
unbound), sets, frozensets, file objects, :term:`generator`\s, type objects,
:class:`DBcursor` objects from the :mod:`bsddb` module, sockets, arrays, deques,
and regular expression pattern objects.
Several builtin types such as :class:`list` and :class:`dict` do not directly
support weak references but can add support through subclassing::
@ -146,7 +146,7 @@ than needed.
.. method:: WeakKeyDictionary.iterkeyrefs()
Return an iterator that yields the weak references to the keys.
Return an :term:`iterator` that yields the weak references to the keys.
.. method:: WeakKeyDictionary.keyrefs()
@ -174,7 +174,7 @@ methods of :class:`WeakKeyDictionary` objects.
.. method:: WeakValueDictionary.itervaluerefs()
Return an iterator that yields the weak references to the values.
Return an :term:`iterator` that yields the weak references to the values.
.. method:: WeakValueDictionary.valuerefs()

View File

@ -124,7 +124,7 @@ also provides these miscellaneous utilities:
.. class:: FileWrapper(filelike [, blksize=8192])
A wrapper to convert a file-like object to an iterator. The resulting objects
A wrapper to convert a file-like object to an :term:`iterator`. The resulting objects
support both :meth:`__getitem__` and :meth:`__iter__` iteration styles, for
compatibility with Python 2.1 and Jython. As the object is iterated over, the
optional *blksize* parameter will be repeatedly passed to the *filelike*

View File

@ -87,7 +87,7 @@ Functions
Parses an XML section into an element tree incrementally, and reports what's
going on to the user. *source* is a filename or file object containing XML data.
*events* is a list of events to report back. If omitted, only "end" events are
reported. Returns an iterator providing ``(event, elem)`` pairs.
reported. Returns an :term:`iterator` providing ``(event, elem)`` pairs.
.. function:: parse(source[, parser])
@ -316,7 +316,7 @@ ElementTree Objects
.. method:: ElementTree.findall(path)
Finds all toplevel elements with the given tag. Same as getroot().findall(path).
*path* is the element to look for. Returns a list or iterator containing all
*path* is the element to look for. Returns a list or :term:`iterator` containing all
matching elements, in document order.

View File

@ -314,7 +314,8 @@ encapsulate multiple calls to a remote server into a single request.
return ``None``, and only store the call name and parameters in the
:class:`MultiCall` object. Calling the object itself causes all stored calls to
be transmitted as a single ``system.multicall`` request. The result of this call
is a generator; iterating over this generator yields the individual results.
is a :term:`generator`; iterating over this generator yields the individual
results.
A usage example of this class is ::

View File

@ -553,7 +553,7 @@ must be given a value in the :meth:`__init__` method or in another method. Both
class and instance variables are accessible through the notation
"``self.name``", and an instance variable hides a class variable with the same
name when accessed in this way. Class variables with immutable values can be
used as defaults for instance variables. Descriptors can be used to create
used as defaults for instance variables. Descriptors can be used to create
instance variables with different implementation details.
.. XXX add link to descriptor docs above

View File

@ -852,7 +852,7 @@ Internal types
single: bytecode
object: code
Code objects represent *byte-compiled* executable Python code, or *bytecode*.
Code objects represent *byte-compiled* executable Python code, or :term:`bytecode`.
The difference between a code object and a function object is that the function
object contains an explicit reference to the function's globals (the module in
which it was defined), while a code object contains no context; also the default
@ -873,7 +873,7 @@ Internal types
used by the bytecode; :attr:`co_names` is a tuple containing the names used by
the bytecode; :attr:`co_filename` is the filename from which the code was
compiled; :attr:`co_firstlineno` is the first line number of the function;
:attr:`co_lnotab` is a string encoding the mapping from byte code offsets to
:attr:`co_lnotab` is a string encoding the mapping from bytecode offsets to
line numbers (for details see the source code of the interpreter);
:attr:`co_stacksize` is the required stack size (including local variables);
:attr:`co_flags` is an integer encoding a number of flags for the interpreter.
@ -1039,6 +1039,7 @@ Internal types
.. % =========================================================================
.. _newstyle:
.. _specialnames:

View File

@ -1273,7 +1273,9 @@ groups from right to left).
.. [#] While comparisons between strings make sense at the byte level, they may
be counter-intuitive to users. For example, the strings ``"\u00C7"`` and
``"\u0327\u0043"`` compare differently, even though they both represent the
same unicode character (LATIN CAPTITAL LETTER C WITH CEDILLA).
same unicode character (LATIN CAPTITAL LETTER C WITH CEDILLA). To compare
strings in a human recognizable way, compare using
:func:`unicodedata.normalize`.
.. [#] The implementation computes this efficiently, without constructing lists
or sorting.

View File

@ -497,7 +497,7 @@ call-next-method and is more powerful than the super call found in
single-inheritance languages.
Dynamic ordering is necessary because all cases of multiple inheritance exhibit
one or more diamond relationships (where one at least one of the parent classes
one or more diamond relationships (where at least one of the parent classes
can be accessed through multiple paths from the bottommost class). For example,
all classes inherit from :class:`object`, so any case of multiple inheritance
provides more than one path to reach :class:`object`. To keep the base classes
@ -707,12 +707,12 @@ returns an object with a :meth:`__next__` method. If the class defines
Generators
==========
Generators are a simple and powerful tool for creating iterators. They are
written like regular functions but use the :keyword:`yield` statement whenever
they want to return data. Each time :func:`next` is called on it, the generator
resumes where it left-off (it remembers all the data values and which statement
was last executed). An example shows that generators can be trivially easy to
create::
:term:`Generator`\s are a simple and powerful tool for creating iterators. They
are written like regular functions but use the :keyword:`yield` statement
whenever they want to return data. Each time :func:`next` is called on it, the
generator resumes where it left-off (it remembers all the data values and which
statement was last executed). An example shows that generators can be trivially
easy to create::
def reverse(data):
for index in range(len(data)-1, -1, -1):

View File

@ -266,8 +266,9 @@ like in C, procedures are just functions that don't return a value. In fact,
technically speaking, procedures do return a value, albeit a rather boring one.
This value is called ``None`` (it's a built-in name). Writing the value
``None`` is normally suppressed by the interpreter if it would be the only value
written. You can see it if you really want to::
written. You can see it if you really want to using :keyword:`print`::
>>> fib(0)
>>> print(fib(0))
None

View File

@ -123,7 +123,7 @@ interpreter. ::
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it: "export PYTHONSTARTUP=/max/home/itamar/.pystartup" in bash.
# to it: "export PYTHONSTARTUP=/home/user/.pystartup" in bash.
#
# Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
# full path to your home directory.

View File

@ -191,8 +191,8 @@ Some tips for experts:
* When the Python interpreter is invoked with the :option:`-O` flag, optimized
code is generated and stored in :file:`.pyo` files. The optimizer currently
doesn't help much; it only removes :keyword:`assert` statements. When
:option:`-O` is used, *all* bytecode is optimized; ``.pyc`` files are ignored
and ``.py`` files are compiled to optimized bytecode.
:option:`-O` is used, *all* :term:`bytecode` is optimized; ``.pyc`` files are
ignored and ``.py`` files are compiled to optimized bytecode.
* Passing two :option:`-O` flags to the Python interpreter (:option:`-OO`) will
cause the bytecode compiler to perform optimizations that could in some rare

View File

@ -67,7 +67,6 @@ new feature.
.. % Large, PEP-level features and changes should be described here.
.. % Should there be a new section here for 3k migration?
.. % Or perhaps a more general section describing module changes/deprecation?
.. % sets module deprecated
.. % ======================================================================
Python 3.0
@ -75,7 +74,23 @@ Python 3.0
.. % XXX add general comment about Python 3.0 features in 2.6
.. % XXX mention -3 switch
The development cycle for Python 2.6 also saw the release of the first
alphas of Python 3.0, and the development of 3.0 has influenced
a number of features in 2.6.
Python 3.0 is a far-ranging redesign of Python that breaks
compatibility with the 2.x series. This means that existing Python
code will need a certain amount of conversion in order to run on
Python 3.0. However, not all the changes in 3.0 necessarily break
compatibility. In cases where new features won't cause existing code
to break, they've been backported to 2.6 and are described in this
document in the appropriate place. Some of the 3.0-derived features
are:
* A :meth:`__complex__` method for converting objects to a complex number.
* Alternate syntax for catching exceptions: ``except TypeError as exc``.
* The addition of :func:`functools.reduce` as a synonym for the built-in
:func:`reduce` function.
A new command-line switch, :option:`-3`, enables warnings
about features that will be removed in Python 3.0. You can run code
@ -406,11 +421,6 @@ Other Language Changes
Here are all of the changes that Python 2.6 makes to the core Python language.
* Changes to the :class:`Exception` interface
as dictated by :pep:`352` continue to be made. For 2.6,
the :attr:`message` attribute is being deprecated in favor of the
:attr:`args` attribute.
* When calling a function using the ``**`` syntax to provide keyword
arguments, you are no longer required to use a Python dictionary;
any mapping will now work::
@ -426,8 +436,29 @@ Here are all of the changes that Python 2.6 makes to the core Python language.
.. % Patch 1686487
* The built-in types now have improved support for extended slicing syntax,
where various combinations of ``(start, stop, step)`` are supplied.
Previously, the support was partial and certain corner cases wouldn't work.
(Implemented by Thomas Wouters.)
.. % Revision 57619
* C functions and methods that use
:cfunc:`PyComplex_AsCComplex` will now accept arguments that
have a :meth:`__complex__` method. In particular, the functions in the
:mod:`cmath` module will now accept objects with this method.
This is a backport of a Python 3.0 change.
(Contributed by Mark Dickinson.)
.. % Patch #1675423
* Changes to the :class:`Exception` interface
as dictated by :pep:`352` continue to be made. For 2.6,
the :attr:`message` attribute is being deprecated in favor of the
:attr:`args` attribute.
* The :func:`compile` built-in function now accepts keyword arguments
as well as positional parameters. (Contributed by XXX.)
as well as positional parameters. (Contributed by Thomas Wouters.)
.. % Patch 1444529
@ -483,21 +514,73 @@ fixes. Here's a partial list of the most notable changes, sorted alphabetically
by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
complete list of changes, or look through the CVS logs for all the details.
* A new data type in the :mod:`collections` module: :class:`NamedTuple(typename,
* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
available, instead of restricting itself to protocol 1.
(Contributed by W. Barnes.)
.. % Patch 1551443
* A new data type in the :mod:`collections` module: :class:`namedtuple(typename,
fieldnames)` is a factory function that creates subclasses of the standard tuple
whose fields are accessible by name as well as index. For example::
var_type = collections.NamedTuple('variable',
'id name type size')
var = var_type(1, 'frequency', 'int', 4)
>>> var_type = collections.namedtuple('variable',
... 'id name type size')
# Names are separated by spaces or commas.
# 'id, name, type, size' would also work.
>>> var_type.__fields__
('id', 'name', 'type', 'size')
print var[0], var.id # Equivalent
print var[2], var.type # Equivalent
>>> var = var_type(1, 'frequency', 'int', 4)
>>> print var[0], var.id # Equivalent
1 1
>>> print var[2], var.type # Equivalent
int int
>>> var.__asdict__()
{'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'}
>>> v2 = var.__replace__('name', 'amplitude')
>>> v2
variable(id=1, name='amplitude', type='int', size=4)
(Contributed by Raymond Hettinger.)
* Another change to the :mod:`collections` module is that the
:class:`deque` type now supports an optional `maxlen` parameter;
if supplied, the deque's size will be restricted to no more
than ``maxlen`` items. Adding more items to a full deque causes
old items to be discarded.
::
>>> from collections import deque
>>> dq=deque(maxlen=3)
>>> dq
deque([], maxlen=3)
>>> dq.append(1) ; dq.append(2) ; dq.append(3)
>>> dq
deque([1, 2, 3], maxlen=3)
>>> dq.append(4)
>>> dq
deque([2, 3, 4], maxlen=3)
(Contributed by Raymond Hettinger.)
* The :mod:`ctypes` module now supports a :class:`c_bool` datatype
that represents the C99 ``bool`` type. (Contributed by David Remahl.)
.. % Patch 1649190
The :mod:`ctypes` string, buffer and array types also have improved
support for extended slicing syntax,
where various combinations of ``(start, stop, step)`` are supplied.
(Implemented by Thomas Wouters.)
.. % Revision 57769
* A new method in the :mod:`curses` module: for a window, :meth:`chgat` changes
the display characters for a certain number of characters on a single line. ::
the display characters for a certain number of characters on a single line.
::
# Boldface text starting at y=0,x=21
# and affecting the rest of the line.
@ -505,11 +588,33 @@ complete list of changes, or look through the CVS logs for all the details.
(Contributed by Fabian Kreutz.)
* The :mod:`decimal` module was updated to version 1.66 of
`the General Decimal Specification <http://www2.hursley.ibm.com/decimal/decarith.html>`__. New features
include some methods for some basic mathematical functions such as
:meth:`exp` and :meth:`log10`::
>>> Decimal(1).exp()
Decimal("2.718281828459045235360287471")
>>> Decimal("2.7182818").ln()
Decimal("0.9999999895305022877376682436")
>>> Decimal(1000).log10()
Decimal("3")
(Implemented by Facundo Batista and Mark Dickinson.)
* An optional ``timeout`` parameter was added to the
:class:`ftplib.FTP` class constructor as well as the :meth:`connect`
method, specifying a timeout measured in seconds. (Added by Facundo
Batista.)
* The :func:`reduce` built-in function is also available in the
:mod:`functools` module. In Python 3.0, the built-in is dropped and it's
only available from :mod:`functools`; currently there are no plans
to drop the built-in in the 2.x series. (Patched by
Christian Heimes.)
.. % Patch 1739906
* The :func:`glob.glob` function can now return Unicode filenames if
a Unicode path was used and Unicode filenames are matched within the directory.
@ -548,7 +653,7 @@ complete list of changes, or look through the CVS logs for all the details.
.. % Patch #1490190
* The :func:`os.walk` function now has a "followlinks" parameter. If
* The :func:`os.walk` function now has a ``followlinks`` parameter. If
set to True, it will follow symlinks pointing to directories and
visit the directory's contents. For backward compatibility, the
parameter's default value is false. Note that the function can fall
@ -557,6 +662,12 @@ complete list of changes, or look through the CVS logs for all the details.
.. % Patch 1273829
* The ``os.environ`` object's :meth:`clear` method will now unset the
environment variables using :func:`os.unsetenv` in addition to clearing
the object's keys. (Contributed by Martin Horcicka.)
.. % Patch #1181
* In the :mod:`os.path` module, the :func:`splitext` function
has been changed to not split on leading period characters.
This produces better results when operating on Unix's dot-files.
@ -574,10 +685,17 @@ complete list of changes, or look through the CVS logs for all the details.
On Windows, :func:`os.path.expandvars` will now expand environment variables
in the form "%var%", and "~user" will be expanded into the
user's home directory path. (Contributed by XXX.)
user's home directory path. (Contributed by Josiah Carlson.)
.. % Patch 957650
* The Python debugger provided by the :mod:`pdb` module
gained a new command: "run" restarts the Python program being debugged,
and can optionally take new command-line arguments for the program.
(Contributed by Rocky Bernstein.)
.. % Patch #1393667
* New functions in the :mod:`posix` module: :func:`chflags` and :func:`lchflags`
are wrappers for the corresponding system calls (where they're available).
Constants for the flag values are defined in the :mod:`stat` module; some
@ -587,6 +705,9 @@ complete list of changes, or look through the CVS logs for all the details.
* The :mod:`rgbimg` module has been removed.
* The :mod:`sets` module has been deprecated; it's better to
use the built-in :class:`set` and :class:`frozenset` types.
* The :mod:`smtplib` module now supports SMTP over SSL thanks to the
addition of the :class:`SMTP_SSL` class. This class supports an
interface identical to the existing :class:`SMTP` class. Both
@ -701,8 +822,47 @@ complete list of changes, or look through the CVS logs for all the details.
(Added by Facundo Batista.)
* The XML-RPC classes :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``
constructor parameter. This can be used to modify the instance's
:attr:`allow_reuse_address` attribute before calling the
:meth:`server_bind` and :meth:`server_activate` methods to
open the socket and begin listening for connections.
(Contributed by Peter Parente.)
.. % Patch 1599845
:class:`SimpleXMLRPCServer` also has a :attr:`_send_traceback_header`
attribute; if true, the exception and formatted traceback are returned
as HTTP headers "X-Exception" and "X-Traceback". This feature is
for debugging purposes only and should not be used on production servers
because the tracebacks could possibly reveal passwords or other sensitive
information. (Contributed by Alan McIntyre as part of his
project for Google's Summer of Code 2007.)
.. % ======================================================================
.. % whole new modules get described in \subsections here
.. % whole new modules get described in subsections here
Improved SSL Support
--------------------------------------------------
Bill Janssen made extensive improvements to Python 2.6's support for
SSL.
XXX use ssl.sslsocket - subclass of socket.socket.
XXX Can specify if certificate is required, and obtain certificate info
by calling getpeercert method.
XXX sslwrap() behaves like socket.ssl
XXX Certain features require the OpenSSL package to be installed, notably
the 'openssl' binary.
.. seealso::
SSL module documentation.
.. % ======================================================================
@ -712,7 +872,13 @@ Build and C API Changes
Changes to Python's build process and to the C API include:
* Detailed changes are listed here.
* The BerkeleyDB module now has a C API object, available as
``bsddb.db.api``. This object can be used by other C extensions
that wish to use the :mod:`bsddb` module for their own purposes.
(Contributed by Duncan Grisby.)
.. % Patch 1551895
.. % ======================================================================
@ -737,7 +903,7 @@ are likely to be underestimates.
Some of the more notable changes are:
* Details go here.
* Details will go here.
.. % ======================================================================
@ -748,8 +914,12 @@ Porting to Python 2.6
This section lists previously described changes that may require changes to your
code:
* The :mod:`socket` module exception :exc:`socket.error` now inherits from
:exc:`IOError`.
* The :mod:`socket` module exception :exc:`socket.error` now inherits
from :exc:`IOError`. Previously it wasn't a subclass of
:exc:`StandardError` but now it is, through :exc:`IOError`.
(Implemented by Gregory P. Smith.)
.. % http://bugs.python.org/issue1706815
.. % ======================================================================