[Python-checkins] peps: Added another run time error example.
eric.smith
python-checkins at python.org
Sat Aug 8 04:25:24 CEST 2015
https://hg.python.org/peps/rev/b658dd445504
changeset: 5926:b658dd445504
user: Eric V. Smith <eric at trueblade.com>
date: Fri Aug 07 22:25:27 2015 -0400
summary:
Added another run time error example.
files:
pep-0498.txt | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/pep-0498.txt b/pep-0498.txt
--- a/pep-0498.txt
+++ b/pep-0498.txt
@@ -276,8 +276,8 @@
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 @@
File "<stdin>", line 2, in <module>
KeyError: 2
+or::
+
+ >>> for x in (32, 100, 'fifty'):
+ ... f'x = {x:+3}'
+ ...
+ 'x = +32'
+ 'x = +100'
+ Traceback (most recent call last):
+ File "<stdin>", line 2, in <module>
+ ValueError: Sign not allowed in string format specifier
+
Leading whitespace in expressions is skipped
--------------------------------------------
--
Repository URL: https://hg.python.org/peps
More information about the Python-checkins
mailing list