Added another run time error example.
This commit is contained in:
parent
84c290c550
commit
fe83f468f6
15
pep-0498.txt
15
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 "<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
|
||||
--------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue