Merged revisions 74861-74863,74876,74896,74930,74933,74952-74953,75015,75019,75260-75263,75265-75266,75289 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74861 | benjamin.peterson | 2009-09-17 05:18:28 +0200 (Do, 17 Sep 2009) | 1 line
pep 8 defaults
........
r74862 | brett.cannon | 2009-09-17 05:24:45 +0200 (Do, 17 Sep 2009) | 1 line
Note in the intro to Extending... that ctypes can be a simpler, more portable solution than custom C code.
........
r74863 | benjamin.peterson | 2009-09-17 05:27:33 +0200 (Do, 17 Sep 2009) | 1 line
rationalize a bit
........
r74876 | georg.brandl | 2009-09-17 18:15:53 +0200 (Do, 17 Sep 2009) | 1 line
#6932: remove paragraph that advises relying on __del__ being called.
........
r74896 | georg.brandl | 2009-09-18 09:22:41 +0200 (Fr, 18 Sep 2009) | 1 line
#6936: for interactive use, quit() is just fine.
........
r74930 | georg.brandl | 2009-09-18 23:21:41 +0200 (Fr, 18 Sep 2009) | 1 line
#6925: rewrite docs for locals() and vars() a bit.
........
r74933 | georg.brandl | 2009-09-18 23:35:59 +0200 (Fr, 18 Sep 2009) | 1 line
#6930: clarify description about byteorder handling in UTF decoder routines.
........
r74952 | georg.brandl | 2009-09-19 12:42:34 +0200 (Sa, 19 Sep 2009) | 1 line
#6946: fix duplicate index entries for datetime classes.
........
r74953 | georg.brandl | 2009-09-19 14:04:16 +0200 (Sa, 19 Sep 2009) | 1 line
Fix references to threading.enumerate().
........
r75015 | georg.brandl | 2009-09-22 12:55:08 +0200 (Di, 22 Sep 2009) | 1 line
Fix encoding name.
........
r75019 | vinay.sajip | 2009-09-22 19:23:41 +0200 (Di, 22 Sep 2009) | 1 line
Fixed a typo, and added sections on optimization and using arbitrary objects as messages.
........
r75260 | andrew.kuchling | 2009-10-05 23:24:20 +0200 (Mo, 05 Okt 2009) | 1 line
Wording fix
........
r75261 | andrew.kuchling | 2009-10-05 23:24:35 +0200 (Mo, 05 Okt 2009) | 1 line
Fix narkup
........
r75262 | andrew.kuchling | 2009-10-05 23:25:03 +0200 (Mo, 05 Okt 2009) | 1 line
Document 'skip' parameter to constructor
........
r75263 | andrew.kuchling | 2009-10-05 23:25:35 +0200 (Mo, 05 Okt 2009) | 1 line
Note side benefit of socket.create_connection()
........
r75265 | andrew.kuchling | 2009-10-06 00:31:11 +0200 (Di, 06 Okt 2009) | 1 line
Reword sentence
........
r75266 | andrew.kuchling | 2009-10-06 00:32:48 +0200 (Di, 06 Okt 2009) | 1 line
Use standard comma punctuation; reword some sentences in the docs
........
r75289 | mark.dickinson | 2009-10-08 22:02:25 +0200 (Do, 08 Okt 2009) | 2 lines
Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting.
........
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index 4678167..5b065b3 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -435,15 +435,33 @@
+---------+----------------------------------------------------------+
| ``'F'`` | Fixed point. Same as ``'f'``. |
+---------+----------------------------------------------------------+
- | ``'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. Infinity and |
- | | NaN values are formatted as ``inf``, ``-inf`` and |
- | | ``nan``, respectively. |
+ | ``'g'`` | General format. For a given precision ``p >= 1``, |
+ | | this rounds the number to ``p`` significant digits and |
+ | | then formats the result in either fixed-point format |
+ | | or in scientific notation, depending on its magnitude. |
+ | | |
+ | | The precise rules are as follows: suppose that the |
+ | | result formatted with presentation type ``'e'`` and |
+ | | precision ``p-1`` would have exponent ``exp``. Then |
+ | | if ``-4 <= exp < p``, the number is formatted |
+ | | with presentation type ``'f'`` and precision |
+ | | ``p-1-exp``. Otherwise, the number is formatted |
+ | | with presentation type ``'e'`` and precision ``p-1``. |
+ | | In both cases insignificant trailing zeros are removed |
+ | | from the significand, and the decimal point is also |
+ | | removed if there are no remaining digits following it. |
+ | | |
+ | | Postive and negative infinity, positive and negative |
+ | | zero, and nans, are formatted as ``inf``, ``-inf``, |
+ | | ``0``, ``-0`` and ``nan`` respectively, regardless of |
+ | | the precision. |
+ | | |
+ | | A precision of ``0`` is treated as equivalent to a |
+ | | precision of ``1``. |
+---------+----------------------------------------------------------+
| ``'G'`` | General format. Same as ``'g'`` except switches to |
- | | ``'E'`` if the number gets to large. The representations |
- | | of infinity and NaN are uppercased, too. |
+ | | ``'E'`` if the number gets too large. The |
+ | | representations of infinity and NaN are uppercased, too. |
+---------+----------------------------------------------------------+
| ``'n'`` | Number. This is the same as ``'g'``, except that it uses |
| | the current locale setting to insert the appropriate |