Added a note that the str.format() parser is not suitable for use when implementing f-strings.

This commit is contained in:
Eric V. Smith 2015-08-27 10:20:59 -04:00
parent 61eadfb105
commit 8af0c666ad
1 changed files with 9 additions and 0 deletions

View File

@ -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.