summaryrefslogtreecommitdiff
path: root/Doc/library/string.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-10-26 11:18:42 +0300
committerGitHub <noreply@github.com>2018-10-26 11:18:42 +0300
commit9a75b8470a2e0de5406edcabba140f023c99c6a9 (patch)
tree74e0edd3fea41339efb614fb4b8b6a8e02f32c5e /Doc/library/string.rst
parentc64c4056c1fce0a18e5810fc6352712612a64010 (diff)
downloadcpython-git-9a75b8470a2e0de5406edcabba140f023c99c6a9.tar.gz
[3.7] bpo-35054: Add more index entries for symbols. (GH-10064). (GH-10120)
(cherry picked from commit ddb961d2abe5d5fde76d85b21a77e4e91e0043ad) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Doc/library/string.rst')
-rw-r--r--Doc/library/string.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index 0fec3df3e3..55913f8c07 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -192,6 +192,15 @@ subclasses can define their own format string syntax). The syntax is
related to that of :ref:`formatted string literals <f-strings>`, but
there are differences.
+.. index::
+ single: {; in string formatting
+ single: }; in string formatting
+ single: .; in string formatting
+ single: [; in string formatting
+ single: ]; in string formatting
+ single: !; in string formatting
+ single: :; in string formatting
+
Format strings contain "replacement fields" surrounded by curly braces ``{}``.
Anything that is not contained in braces is considered literal text, which is
copied unchanged to the output. If you need to include a brace character in the
@@ -323,6 +332,12 @@ affect the :func:`format` function.
The meaning of the various alignment options is as follows:
+ .. index::
+ single: <; in string formatting
+ single: >; in string formatting
+ single: =; in string formatting
+ single: ^; in string formatting
+
+---------+----------------------------------------------------------+
| Option | Meaning |
+=========+==========================================================+
@@ -349,6 +364,11 @@ meaning in this case.
The *sign* option is only valid for number types, and can be one of the
following:
+ .. index::
+ single: +; in string formatting
+ single: -; in string formatting
+ single: space; in string formatting
+
+---------+----------------------------------------------------------+
| Option | Meaning |
+=========+==========================================================+
@@ -363,6 +383,8 @@ following:
+---------+----------------------------------------------------------+
+.. index:: single: #; in string formatting
+
The ``'#'`` option causes the "alternate form" to be used for the
conversion. The alternate form is defined differently for different
types. This option is only valid for integer, float, complex and
@@ -375,6 +397,8 @@ decimal-point character appears in the result of these conversions
only if a digit follows it. In addition, for ``'g'`` and ``'G'``
conversions, trailing zeros are not removed from the result.
+.. index:: single: ,; in string formatting
+
The ``','`` option signals the use of a comma for a thousands separator.
For a locale aware separator, use the ``'n'`` integer presentation type
instead.
@@ -382,6 +406,8 @@ instead.
.. versionchanged:: 3.1
Added the ``','`` option (see also :pep:`378`).
+.. index:: single: _; in string formatting
+
The ``'_'`` option signals the use of an underscore for a thousands
separator for floating point presentation types and for integer
presentation type ``'d'``. For integer presentation types ``'b'``,
@@ -668,6 +694,8 @@ formatting facilities in Python. As an example of a library built on template
strings for i18n, see the
`flufl.i18n <http://flufli18n.readthedocs.io/en/latest/>`_ package.
+.. index:: single: $; in template strings
+
Template strings support ``$``-based substitutions, using the following rules:
* ``$$`` is an escape; it is replaced with a single ``$``.