mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
Merged revisions 74210,74239,74252-74253,74256,74258-74261,74332-74333,74404,74411,74445,74465,74467,74488 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74210 | georg.brandl | 2009-07-26 16:44:23 +0200 (So, 26 Jul 2009) | 1 line Move member descriptions inside the classes. ........ r74239 | georg.brandl | 2009-07-28 20:55:32 +0200 (Di, 28 Jul 2009) | 1 line Clarify quote_plus() usage. ........ r74252 | georg.brandl | 2009-07-29 18:06:31 +0200 (Mi, 29 Jul 2009) | 1 line #6593: fix link targets. ........ r74253 | georg.brandl | 2009-07-29 18:09:17 +0200 (Mi, 29 Jul 2009) | 1 line #6591: add reference to ioctl in fcntl module for platforms other than Windows. ........ r74256 | georg.brandl | 2009-07-29 18:32:30 +0200 (Mi, 29 Jul 2009) | 1 line #6336: Add nb_divide. ........ r74258 | georg.brandl | 2009-07-29 18:57:05 +0200 (Mi, 29 Jul 2009) | 1 line Add a link to readline, and mention IPython and bpython. ........ r74259 | georg.brandl | 2009-07-29 19:07:21 +0200 (Mi, 29 Jul 2009) | 1 line Fix some markup and small factual glitches found by M. Markert. ........ r74260 | georg.brandl | 2009-07-29 19:15:20 +0200 (Mi, 29 Jul 2009) | 1 line Fix a few markup glitches. ........ r74261 | georg.brandl | 2009-07-29 19:50:25 +0200 (Mi, 29 Jul 2009) | 1 line Rewrite the section about classes a bit; mostly tidbits, and a larger update to the section about "private" variables to reflect the Pythonic consensus better. ........ r74332 | georg.brandl | 2009-08-06 19:23:21 +0200 (Do, 06 Aug 2009) | 1 line Fix punctuation and one copy-paste error. ........ r74333 | georg.brandl | 2009-08-06 19:43:55 +0200 (Do, 06 Aug 2009) | 1 line #6658: fix two typos. ........ r74404 | georg.brandl | 2009-08-13 14:05:52 +0200 (Do, 13 Aug 2009) | 1 line Use locale.format_string() for more than one specifier. ........ r74411 | georg.brandl | 2009-08-13 14:57:25 +0200 (Do, 13 Aug 2009) | 2 lines Remove potentially confusing sentence in __mangling description. ........ r74445 | vinay.sajip | 2009-08-14 13:33:54 +0200 (Fr, 14 Aug 2009) | 1 line Added versionchanged notices for optional 'delay' parameter to file handler classes. ........ r74465 | vinay.sajip | 2009-08-16 01:23:12 +0200 (So, 16 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-16 01:34:47 +0200 (So, 16 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 15:14:37 +0200 (Mo, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........
This commit is contained in:
parent
4ae4f876a2
commit
46e9daa3ae
13 changed files with 326 additions and 285 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue