Fixed code typos. Minor rewording.
This commit is contained in:
parent
1429bb2ec2
commit
8886508947
12
pep-0498.txt
12
pep-0498.txt
|
@ -306,18 +306,18 @@ Leading whitespace in expressions is skipped
|
|||
Because expressions may begin with a left brace ('{'), there is a
|
||||
problem when parsing such expressions. For example::
|
||||
|
||||
>>> f'{{k:v for k, v in [(1, 2), (3, 4)}}'
|
||||
'{k:v for k, v in [(1, 2), (3, 4)}'
|
||||
>>> f'{{k:v for k, v in [(1, 2), (3, 4)]}}'
|
||||
'{k:v for k, v in [(1, 2), (3, 4)]}'
|
||||
|
||||
In this case, the doubled left braces and doubled right braces are
|
||||
interpreted as single braces, and the string becomes just a normal
|
||||
string literal. There is no expression evaluation being performed.
|
||||
|
||||
To account for this, whitespace characters at the beginning of an
|
||||
expression are skipped::
|
||||
To allow for expressions to begin with a left brace, whitespace
|
||||
characters at the beginning of an expression are skipped::
|
||||
|
||||
>>> f'{ {k:v for k, v in [(1, 2), (3, 4)}}'
|
||||
'{k:v for k, v in [(1, 2), (3, 4)}'
|
||||
>>> f'{ {k:v for k, v in [(1, 2), (3, 4)]}}'
|
||||
'{1: 2, 3: 4}'
|
||||
|
||||
Discussion
|
||||
==========
|
||||
|
|
Loading…
Reference in New Issue