Spell checked.
This commit is contained in:
parent
55d84e727c
commit
3732c04a7a
10
pep-0498.txt
10
pep-0498.txt
|
@ -18,7 +18,7 @@ Python supports multiple ways to format text strings. These include
|
||||||
[#]_. Each of these methods have their advantages, but in addition
|
[#]_. Each of these methods have their advantages, but in addition
|
||||||
have disadvantages that make them cumbersome to use in practice. This
|
have disadvantages that make them cumbersome to use in practice. This
|
||||||
PEP proposed to add a new string formatting mechanism: Literal String
|
PEP proposed to add a new string formatting mechanism: Literal String
|
||||||
Interpolation. In this PEP, such strings will be refered to as
|
Interpolation. In this PEP, such strings will be referred to as
|
||||||
"f-strings", taken from the leading character used to denote such
|
"f-strings", taken from the leading character used to denote such
|
||||||
strings, and standing for "formatted strings".
|
strings, and standing for "formatted strings".
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ that applies to ``str``, not to the type of the expression.
|
||||||
Similar to ``str.format()``, optional format specifiers maybe be
|
Similar to ``str.format()``, optional format specifiers maybe be
|
||||||
included inside the f-string, separated from the expression (or the
|
included inside the f-string, separated from the expression (or the
|
||||||
type conversion, if specified) by a colon. If a format specifier is
|
type conversion, if specified) by a colon. If a format specifier is
|
||||||
not provied, an empty string is used.
|
not provided, an empty string is used.
|
||||||
|
|
||||||
So, an f-string looks like::
|
So, an f-string looks like::
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ format specifier. The resulting value is used when building the value
|
||||||
of the f-string.
|
of the f-string.
|
||||||
|
|
||||||
Expressions cannot contain ``':'`` or ``'!'`` outside of strings or
|
Expressions cannot contain ``':'`` or ``'!'`` outside of strings or
|
||||||
parens, brackets, or braces. The exception is that the ``'!='``
|
parentheses, brackets, or braces. The exception is that the ``'!='``
|
||||||
operator is allowed as a special case.
|
operator is allowed as a special case.
|
||||||
|
|
||||||
Escape sequences
|
Escape sequences
|
||||||
|
@ -437,7 +437,7 @@ How to denote f-strings
|
||||||
Because the compiler must be involved in evaluating the expressions
|
Because the compiler must be involved in evaluating the expressions
|
||||||
contained in the interpolated strings, there must be some way to
|
contained in the interpolated strings, there must be some way to
|
||||||
denote to the compiler which strings should be evaluated. This PEP
|
denote to the compiler which strings should be evaluated. This PEP
|
||||||
chose a leading ``'f'`` character preceeding the string literal. This
|
chose a leading ``'f'`` character preceding the string literal. This
|
||||||
is similar to how ``'b'`` and ``'r'`` prefixes change the meaning of
|
is similar to how ``'b'`` and ``'r'`` prefixes change the meaning of
|
||||||
the string itself, at compile time. Other prefixes were suggested,
|
the string itself, at compile time. Other prefixes were suggested,
|
||||||
such as ``'i'``. No option seemed better than the other, so ``'f'``
|
such as ``'i'``. No option seemed better than the other, so ``'f'``
|
||||||
|
@ -621,7 +621,7 @@ expression is seen and is syntactically invalid. As there's no
|
||||||
practical use for a plain lambda in an f-string expression, this is
|
practical use for a plain lambda in an f-string expression, this is
|
||||||
not seen as much of a limitation.
|
not seen as much of a limitation.
|
||||||
|
|
||||||
If you feel you must use lambdas, they may be used inside of parens::
|
If you feel you must use lambdas, they may be used inside of parentheses::
|
||||||
|
|
||||||
>>> f'{(lambda x: x*2)(3)}'
|
>>> f'{(lambda x: x*2)(3)}'
|
||||||
'6'
|
'6'
|
||||||
|
|
Loading…
Reference in New Issue