diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-07-26 22:27:04 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-07-26 22:27:04 (GMT) |
commit | 711419388c4316717a1cb8e018a6f84d495fa1bf (patch) | |
tree | f9851ed13bb341bcd730ffbfc53d80ad8296a7fa | |
parent | 0cea15736260ca4a43c666c0fec3faaa47e67346 (diff) | |
download | cpython-711419388c4316717a1cb8e018a6f84d495fa1bf.zip cpython-711419388c4316717a1cb8e018a6f84d495fa1bf.tar.gz cpython-711419388c4316717a1cb8e018a6f84d495fa1bf.tar.bz2 |
Merged revisions 65253 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65253 | georg.brandl | 2008-07-26 17:13:29 -0500 (Sat, 26 Jul 2008) | 2 lines
Shorten some overlong lines.
........
-rw-r--r-- | Doc/tutorial/inputoutput.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index af074dd..bf1c79f 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -146,12 +146,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 @@ -179,7 +181,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 '**' |