diff options
author | Christian Heimes <christian@cheimes.de> | 2008-03-26 13:45:42 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-03-26 13:45:42 (GMT) |
commit | f6cd967e2c204238cb4fe56c7e842cf7766ddd01 (patch) | |
tree | 87e1621f83f96e1bd794fbcc72373f3c88249205 /Doc/whatsnew/2.6.rst | |
parent | 41be953df02d7101dc921f94c3c60a6e4b381538 (diff) | |
download | cpython-f6cd967e2c204238cb4fe56c7e842cf7766ddd01.zip cpython-f6cd967e2c204238cb4fe56c7e842cf7766ddd01.tar.gz cpython-f6cd967e2c204238cb4fe56c7e842cf7766ddd01.tar.bz2 |
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
Diffstat (limited to 'Doc/whatsnew/2.6.rst')
-rw-r--r-- | Doc/whatsnew/2.6.rst | 95 |
1 files changed, 78 insertions, 17 deletions
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index 0e8901b..9299c01 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -555,10 +555,11 @@ adding a colon followed by a format specifier. For example:: Format specifiers can reference other fields through nesting:: fmt = '{0:{1}}' - fmt.format('Invoice #1234', width) -> - 'Invoice #1234 ' fmt.format('Invoice #1234', 15) -> 'Invoice #1234 ' + width = 35 + fmt.format('Invoice #1234', width) -> + 'Invoice #1234 ' The alignment of a field within the desired width can be specified: @@ -571,11 +572,38 @@ Character Effect = (For numeric types only) Pad after the sign. ================ ============================================ -Format data types:: - - ... XXX take table from PEP 3101 - -Classes and types can define a __format__ method to control how it's +Format specifiers can also include a presentation type, which +controls how the value is formatted. For example, floating-point numbers +can be formatted as a general number or in exponential notation: + + >>> '{0:g}'.format(3.75) + '3.75' + >>> '{0:e}'.format(3.75) + '3.750000e+00' + +A variety of presentation types are available. Consult the 2.6 +documentation for a complete list (XXX add link, once it's in the 2.6 +docs), but here's a sample:: + + 'b' - Binary. Outputs the number in base 2. + 'c' - Character. Converts the integer to the corresponding + Unicode character before printing. + 'd' - Decimal Integer. Outputs the number in base 10. + 'o' - Octal format. Outputs the number in base 8. + 'x' - Hex format. Outputs the number in base 16, using lower- + case letters for the digits above 9. + 'e' - Exponent notation. Prints the number in scientific + notation using the letter 'e' to indicate the exponent. + 'g' - General format. This prints the number as a fixed-point + number, unless the number is too large, in which case + it switches to 'e' exponent notation. + 'n' - Number. This is the same as 'g', except that it uses the + current locale setting to insert the appropriate + number separator characters. + '%' - Percentage. Multiplies the number by 100 and displays + in fixed ('f') format, followed by a percent sign. + +Classes and types can define a __format__ method to control how they're formatted. It receives a single argument, the format specifier:: def __format__(self, format_spec): @@ -610,7 +638,6 @@ function from somewhere else. Python 2.6 has a ``__future__`` import that removes ``print`` as language syntax, letting you use the functional form instead. For example:: - XXX need to check from __future__ import print_function print('# of entries', len(dictionary), file=sys.stderr) @@ -701,6 +728,21 @@ and it also supports the ``b''`` notation. .. ====================================================================== +.. _pep-3118: + +PEP 3118: Revised Buffer Protocol +===================================================== + +The buffer protocol is a C-level API that lets Python extensions +XXX + +.. seealso:: + + :pep:`3118` - Revising the buffer protocol + PEP written by Travis Oliphant and Carl Banks. + +.. ====================================================================== + .. _pep-3119: PEP 3119: Abstract Base Classes @@ -1082,7 +1124,7 @@ Optimizations by using pymalloc for the Unicode string's data. * The ``with`` statement now stores the :meth:`__exit__` method on the stack, - producing a small speedup. (Implemented by Nick Coghlan.) + producing a small speedup. (Implemented by Jeffrey Yasskin.) * To reduce memory usage, the garbage collector will now clear internal free lists when garbage-collecting the highest generation of objects. @@ -1361,10 +1403,8 @@ complete list of changes, or look through the CVS logs for all the details. the forward search. (Contributed by John Lenton.) -* The :mod:`new` module has been removed from Python 3.0. - Importing it therefore - triggers a warning message when Python is running in 3.0-warning - mode. +* (3.0-warning mode) The :mod:`new` module has been removed from + Python 3.0. Importing it therefore triggers a warning message. * The :mod:`operator` module gained a :func:`methodcaller` function that takes a name and an optional @@ -1483,6 +1523,14 @@ complete list of changes, or look through the CVS logs for all the details. .. Issue 1727780 + The new ``triangular(low, high, mode)`` function returns random + numbers following a triangular distribution. The returned values + are between *low* and *high*, not including *high* itself, and + with *mode* as the mode, the most frequently occurring value + in the distribution. (Contributed by Raymond Hettinger. XXX check) + + .. Patch 1681432 + * Long regular expression searches carried out by the :mod:`re` module will now check for signals being delivered, so especially long searches can now be interrupted. @@ -1500,6 +1548,16 @@ complete list of changes, or look through the CVS logs for all the details. .. Patch 1861 +* The :mod:`select` module now has wrapper functions + for the Linux :cfunc:`epoll` and BSD :cfunc:`kqueue` system calls. + Also, a :meth:`modify` method was added to the existing :class:`poll` + objects; ``pollobj.modify(fd, eventmask)`` takes a file descriptor + or file object and an event mask, + + (Contributed by XXX.) + + .. Patch 1657 + * The :mod:`sets` module has been deprecated; it's better to use the built-in :class:`set` and :class:`frozenset` types. @@ -1948,9 +2006,8 @@ Some of the more notable changes are: Porting to Python 2.6 ===================== -This section lists previously described changes, and a few -esoteric bugfixes, that may require changes to your -code: +This section lists previously described changes and other bugfixes +that may require changes to your code: * The :meth:`__init__` method of :class:`collections.deque` now clears any existing contents of the deque @@ -1986,7 +2043,11 @@ code: .. Issue 1330538 -* In 3.0-warning mode, inequality comparisons between two dictionaries +* (3.0-warning mode) The :class:`Exception` class now warns + when accessed using slicing or index access; having + :class:`Exception` behave like a tuple is being phased out. + +* (3.0-warning mode) inequality comparisons between two dictionaries or two objects that don't implement comparison methods are reported as warnings. ``dict1 == dict2`` still works, but ``dict1 < dict2`` is being phased out. |