From 14bb28aa6270e5d9c3b22f00f920fa1340f026e9 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 29 Jul 2009 17:15:20 +0000 Subject: [PATCH] Fix a few markup glitches. --- Doc/tutorial/inputoutput.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index bfbc9a62fdc..9352f40908e 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -127,16 +127,17 @@ Basic usage of the :meth:`str.format` method looks like this:: We are the knights who say "Ni!" The brackets and characters within them (called format fields) are replaced with -the objects passed into the format method. The number in the brackets refers to -the position of the object passed into the format method. :: +the objects passed into the :meth:`~str.format` method. The number in the +brackets refers to the position of the object passed into the +: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 format method, their values are referred to -by using the name of the argument. :: +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( ... food='spam', adjective='absolutely horrible') @@ -157,7 +158,7 @@ truncates Pi to three places after the decimal. The value of PI is approximately 3.142. Passing an integer after the ``':'`` will cause that field to be a minimum -number of characters wide. This is useful for making tables pretty.:: +number of characters wide. This is useful for making tables pretty. :: >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} >>> for name, phone in table.items(): @@ -178,7 +179,7 @@ square brackets ``'[]'`` to access the keys :: Jack: 4098; Sjoerd: 4127; Dcab: 8637678 This could also be done by passing the table as keyword arguments with the '**' -notation.:: +notation. :: >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678} >>> print 'Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table) @@ -356,9 +357,9 @@ shorter than writing equivalent :keyword:`try`\ -\ :keyword:`finally` blocks:: >>> f.closed True -File objects have some additional methods, such as :meth:`isatty` and -:meth:`truncate` which are less frequently used; consult the Library Reference -for a complete guide to file objects. +File objects have some additional methods, such as :meth:`~file.isatty` and +:meth:`~file.truncate` which are less frequently used; consult the Library +Reference for a complete guide to file objects. .. _tut-pickle: