summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-07-26 22:13:29 (GMT)
committerGeorg Brandl <georg@python.org>2008-07-26 22:13:29 (GMT)
commit4b99e9b4790af9951b81925e28bd07850cb5c630 (patch)
tree8cfeae92d75cb655ea4b83fdefc76a193ffd2948 /Doc/tutorial
parent36897e1ff96d1f4254b55634aae8a3bc3d89491a (diff)
downloadcpython-4b99e9b4790af9951b81925e28bd07850cb5c630.zip
cpython-4b99e9b4790af9951b81925e28bd07850cb5c630.tar.gz
cpython-4b99e9b4790af9951b81925e28bd07850cb5c630.tar.bz2
Shorten some overlong lines.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/inputoutput.rst9
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 1b344e6..22bad74 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -143,12 +143,14 @@ the position of the object passed into the format method. ::
If keyword arguments are used in the 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')
+ >>> print 'This {food} is {adjective}.'.format(
+ ... food='spam', adjective='absolutely horrible')
This spam is absolutely horrible.
Positional and keyword arguments can be arbitrarily combined::
- >>> print 'The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred', other='Georg')
+ >>> print 'The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred',
+ ... other='Georg')
The story of Bill, Manfred, and Georg.
An optional ``':``` and format specifier can follow the field name. This also
@@ -176,7 +178,8 @@ instead of by position. This can be done by simply passing the dict and using
square brackets ``'[]'`` to access the keys ::
>>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
- >>> print 'Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; Dcab: {0[Dcab]:d}'.format(table)
+ >>> print ('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '
+ ... 'Dcab: {0[Dcab]:d}'.format(table))
Jack: 4098; Sjoerd: 4127; Dcab: 8637678
This could also be done by passing the table as keyword arguments with the '**'