Added a note that the str.format() parser is not suitable for use when implementing f-strings.
This commit is contained in:
parent
61eadfb105
commit
8af0c666ad
|
@ -470,6 +470,15 @@ use variables as index values::
|
|||
>>> f'a={d[a]}'
|
||||
'a=20'
|
||||
|
||||
Furthermore, the limited expressions that str.format() understands
|
||||
need not be valid Python expressions. For example::
|
||||
|
||||
>>> '{i[";]}'.format(i={'";':4})
|
||||
'4'
|
||||
|
||||
For this reason, the str.format() "expression parser" is not suitable
|
||||
for use when implementing f-strings.
|
||||
|
||||
See [#]_ for a further discussion. It was this observation that led to
|
||||
full Python expressions being supported in f-strings.
|
||||
|
||||
|
|
Loading…
Reference in New Issue