From acf7aa34da6ecd3417fe4dc01f0b43b402924fcb Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Mon, 10 Aug 2015 09:17:36 -0400 Subject: [PATCH] Small typos. Added section about nested expressions inside format specifiers. --- pep-0498.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pep-0498.txt b/pep-0498.txt index 33de1e3eb..73b3612d0 100644 --- a/pep-0498.txt +++ b/pep-0498.txt @@ -229,7 +229,17 @@ Is equivalent to:: Format specifiers ----------------- -Format specifiers are not interpreted by the f-string parser. Just as +Format specifiers may also contain evaluated expressions. This allows +code such as:: + + >>> width = 10 + >>> precision = 4 + >>> value = decimal.Decimal('12.34567') + >>> f'result: {value:{width}.{prevision}}' + 'result: 12.35' + +Once expressions in a format specifier are evaluated (if necessary), +format specifiers are not interpreted by the f-string evaluator. Just as in str.format(), they are merely passed in to the __format__() method of the object being formatted. @@ -325,7 +335,7 @@ Discussion Most of the discussions on python-ideas [#]_ focused on a few issues: - Whether to allow full Python expressions. - - How to designate f-strings, and how specify the locaton of + - How to designate f-strings, and how to specify the location of expressions in them. - How to concatenate adjacent strings and f-strings.