summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorLogan Jones <loganasherjones@gmail.com>2019-05-06 16:32:44 (GMT)
committerGuido van Rossum <guido@python.org>2019-05-06 16:32:44 (GMT)
commitae2c32f32b61f3b141ba4b0b1ad71781d2f9a1a1 (patch)
treeae667e7364dceb0717120a9f0d160cfffa4c222e /Doc/reference
parentf7b494c4d473c99ade2c8ab4e63005552f168f2b (diff)
downloadcpython-ae2c32f32b61f3b141ba4b0b1ad71781d2f9a1a1.zip
cpython-ae2c32f32b61f3b141ba4b0b1ad71781d2f9a1a1.tar.gz
cpython-ae2c32f32b61f3b141ba4b0b1ad71781d2f9a1a1.tar.bz2
bpo-36798: Updating f-string docs for := use case (GH-13107)
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/lexical_analysis.rst11
1 files changed, 6 insertions, 5 deletions
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst
index fb04ccc..13adc1a 100644
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -680,11 +680,12 @@ with a closing curly bracket ``'}'``.
Expressions in formatted string literals are treated like regular
Python expressions surrounded by parentheses, with a few exceptions.
-An empty expression is not allowed, and a :keyword:`lambda` expression
-must be surrounded by explicit parentheses. Replacement expressions
-can contain line breaks (e.g. in triple-quoted strings), but they
-cannot contain comments. Each expression is evaluated in the context
-where the formatted string literal appears, in order from left to right.
+An empty expression is not allowed, and both :keyword:`lambda` and
+assignment expressions ``:=`` must be surrounded by explicit parentheses.
+Replacement expressions can contain line breaks (e.g. in triple-quoted
+strings), but they cannot contain comments. Each expression is evaluated
+in the context where the formatted string literal appears, in order from
+left to right.
If a conversion is specified, the result of evaluating the expression
is converted before formatting. Conversion ``'!s'`` calls :func:`str` on