[Python-checkins] cpython (merge 3.1 -> 3.2): Merge with 3.1.

ezio.melotti python-checkins at python.org
Sun Mar 13 01:28:17 CET 2011


http://hg.python.org/cpython/rev/4a68f4cfbdc8
changeset:   68413:4a68f4cfbdc8
branch:      3.2
parent:      68406:2a03c5979ea8
parent:      68411:87167b08312f
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Sun Mar 13 02:27:26 2011 +0200
summary:
  Merge with 3.1.

files:
  Doc/tutorial/inputoutput.rst

diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -40,8 +40,8 @@
 there is not equivalent syntax).  For objects which don't have a particular
 representation for human consumption, :func:`str` will return the same value as
 :func:`repr`.  Many values, such as numbers or structures like lists and
-dictionaries, have the same representation using either function.  Strings and
-floating point numbers, in particular, have two distinct representations.
+dictionaries, have the same representation using either function.  Strings, in
+particular, have two distinct representations.
 
 Some examples::
 
@@ -50,9 +50,7 @@
    'Hello, world.'
    >>> repr(s)
    "'Hello, world.'"
-   >>> str(1.0/7.0)
-   '0.142857142857'
-   >>> repr(1.0/7.0)
+   >>> str(1/7)
    '0.14285714285714285'
    >>> x = 10 * 3.25
    >>> y = 200 * 200
@@ -103,17 +101,18 @@
 (Note that in the first example, one space between each column was added by the
 way :func:`print` works: it always adds spaces between its arguments.)
 
-This example demonstrates the :meth:`rjust` method of string objects, which
-right-justifies a string in a field of a given width by padding it with spaces
-on the left.  There are similar methods :meth:`ljust` and :meth:`center`.  These
-methods do not write anything, they just return a new string.  If the input
-string is too long, they don't truncate it, but return it unchanged; this will
-mess up your column lay-out but that's usually better than the alternative,
-which would be lying about a value.  (If you really want truncation you can
-always add a slice operation, as in ``x.ljust(n)[:n]``.)
+This example demonstrates the :meth:`str.rjust` method of string
+objects, which right-justifies a string in a field of a given width by padding
+it with spaces on the left.  There are similar methods :meth:`str.ljust` and
+:meth:`str.center`.  These methods do not write anything, they just return a
+new string.  If the input string is too long, they don't truncate it, but
+return it unchanged; this will mess up your column lay-out but that's usually
+better than the alternative, which would be lying about a value.  (If you
+really want truncation you can always add a slice operation, as in
+``x.ljust(n)[:n]``.)
 
-There is another method, :meth:`zfill`, which pads a numeric string on the left
-with zeros.  It understands about plus and minus signs::
+There is another method, :meth:`str.zfill`, which pads a numeric string on the
+left with zeros.  It understands about plus and minus signs::
 
    >>> '12'.zfill(5)
    '00012'
@@ -128,16 +127,16 @@
    We are the knights who say "Ni!"
 
 The brackets and characters within them (called format fields) are replaced with
-the objects passed into the :meth:`~str.format` method.  A number in the
+the objects passed into the :meth:`str.format` method.  A number in the
 brackets can be used to refer to the position of the object passed into the
-:meth:`~str.format` method. ::
+:meth:`str.format` method. ::
 
    >>> print('{0} and {1}'.format('spam', 'eggs'))
    spam and eggs
    >>> print('{1} and {0}'.format('spam', 'eggs'))
    eggs and spam
 
-If keyword arguments are used in the :meth:`~str.format` method, their values
+If keyword arguments are used in the :meth:`str.format` method, their values
 are referred to by using the name of the argument. ::
 
    >>> print('This {food} is {adjective}.'.format(
@@ -195,8 +194,8 @@
    >>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))
    Jack: 4098; Sjoerd: 4127; Dcab: 8637678
 
-This is particularly useful in combination with the new built-in :func:`vars`
-function, which returns a dictionary containing all local variables.
+This is particularly useful in combination with the built-in function
+:func:`vars`, which returns a dictionary containing all local variables.
 
 For a complete overview of string formatting with :meth:`str.format`, see
 :ref:`formatstrings`.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list