]> granicus.if.org Git - python/commitdiff
remove auto-numbered format fields
authorBenjamin Peterson <benjamin@python.org>
Wed, 6 Jan 2010 00:55:21 +0000 (00:55 +0000)
committerBenjamin Peterson <benjamin@python.org>
Wed, 6 Jan 2010 00:55:21 +0000 (00:55 +0000)
Doc/tutorial/inputoutput.rst

index 0259749ee21c4b50065edf48bd52a591fb1cf6d4..a2dda3bf152aff4487a1dde431d920c299c61802 100644 (file)
@@ -123,7 +123,7 @@ with zeros.  It understands about plus and minus signs::
 
 Basic usage of the :meth:`str.format` method looks like this::
 
-   >>> print 'We are the {} who say "{}!"'.format('knights', 'Ni')
+   >>> print 'We are the {0} who say "{1}!"'.format('knights', 'Ni')
    We are the knights who say "Ni!"
 
 The brackets and characters within them (called format fields) are replaced with
@@ -153,9 +153,9 @@ Positional and keyword arguments can be arbitrarily combined::
 convert the value before it is formatted. ::
 
    >>> import math
-   >>> print 'The value of PI is approximately {}.'.format(math.pi)
+   >>> print 'The value of PI is approximately {0}.'.format(math.pi)
    The value of PI is approximately 3.14159265359.
-   >>> print 'The value of PI is approximately {!r}.'.format(math.pi)
+   >>> print 'The value of PI is approximately {0!r}.'.format(math.pi)
    The value of PI is approximately 3.141592653589793.
 
 An optional ``':'`` and format specifier can follow the field name. This allows