Issue #25179: Documentation for formatted string literals aka f-strings

Some of the inspiration and wording is taken from the text of PEP 498 by Eric
V. Smith, and the existing str.format() documentation.
This commit is contained in:
Martin Panter 2016-02-13 00:41:37 +00:00
parent e0b23095ee
commit bc1ee460dc
10 changed files with 158 additions and 21 deletions

View file

@ -25,7 +25,8 @@ first way is to do all the string handling yourself; using string slicing and
concatenation operations you can create any layout you can imagine. The
string type has some methods that perform useful operations for padding
strings to a given column width; these will be discussed shortly. The second
way is to use the :meth:`str.format` method.
way is to use :ref:`formatted string literals <f-strings>`, or the
:meth:`str.format` method.
The :mod:`string` module contains a :class:`~string.Template` class which offers
yet another way to substitute values into strings.

View file

@ -352,6 +352,9 @@ The built-in function :func:`len` returns the length of a string::
Strings support a large number of methods for
basic transformations and searching.
:ref:`f-strings`
String literals that have embedded expressions.
:ref:`formatstrings`
Information about string formatting with :meth:`str.format`.