From 8af0c666ad99ba27ede4352bc8714c333e9d8d84 Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Thu, 27 Aug 2015 10:20:59 -0400 Subject: [PATCH] Added a note that the str.format() parser is not suitable for use when implementing f-strings. --- pep-0498.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pep-0498.txt b/pep-0498.txt index d58f7f01f..85b028f80 100644 --- a/pep-0498.txt +++ b/pep-0498.txt @@ -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.