From fe83f468f6b53c3223b2ab5ad7b49d5be51ac458 Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Fri, 7 Aug 2015 22:25:27 -0400 Subject: [PATCH] Added another run time error example. --- pep-0498.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pep-0498.txt b/pep-0498.txt index 60b8c3ec9..e217d0342 100644 --- a/pep-0498.txt +++ b/pep-0498.txt @@ -276,8 +276,8 @@ Invalid expressions:: SyntaxError: invalid syntax Run time errors occur when evaluating the expressions inside an -f-string. Note that an f-string can be executed multiple times, and -work sometimes and raise an error other times:: +f-string. Note that an f-string can be evaluated multiple times, and +work sometimes and raise an error at other times:: >>> d = {0:10, 1:20} >>> for i in range(3): @@ -289,6 +289,17 @@ work sometimes and raise an error other times:: File "", line 2, in KeyError: 2 +or:: + + >>> for x in (32, 100, 'fifty'): + ... f'x = {x:+3}' + ... + 'x = +32' + 'x = +100' + Traceback (most recent call last): + File "", line 2, in + ValueError: Sign not allowed in string format specifier + Leading whitespace in expressions is skipped --------------------------------------------