mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
bpo-36798: Updating f-string docs for := use case (GH-13107)
This commit is contained in:
parent
f7b494c4d4
commit
ae2c32f32b
1 changed files with 6 additions and 5 deletions
|
|
@ -680,11 +680,12 @@ with a closing curly bracket ``'}'``.
|
||||||
|
|
||||||
Expressions in formatted string literals are treated like regular
|
Expressions in formatted string literals are treated like regular
|
||||||
Python expressions surrounded by parentheses, with a few exceptions.
|
Python expressions surrounded by parentheses, with a few exceptions.
|
||||||
An empty expression is not allowed, and a :keyword:`lambda` expression
|
An empty expression is not allowed, and both :keyword:`lambda` and
|
||||||
must be surrounded by explicit parentheses. Replacement expressions
|
assignment expressions ``:=`` must be surrounded by explicit parentheses.
|
||||||
can contain line breaks (e.g. in triple-quoted strings), but they
|
Replacement expressions can contain line breaks (e.g. in triple-quoted
|
||||||
cannot contain comments. Each expression is evaluated in the context
|
strings), but they cannot contain comments. Each expression is evaluated
|
||||||
where the formatted string literal appears, in order from left to right.
|
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
|
If a conversion is specified, the result of evaluating the expression
|
||||||
is converted before formatting. Conversion ``'!s'`` calls :func:`str` on
|
is converted before formatting. Conversion ``'!s'`` calls :func:`str` on
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue