Skip to content

Commit ebe2dde

Browse files
committed
Touch ups
1 parent 31caa6f commit ebe2dde

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Doc/reference/expressions.rst

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,18 @@ Formally, the syntax for atoms is:
6868
| `builtin_constant`
6969
| `identifier`
7070
| `literal`
71-
| `enclosure`
72-
builtin_constant:
73-
| 'True'
74-
| 'False'
75-
| 'None'
76-
| '...'
77-
enclosure:
71+
| `parenthesized_enclosure`
72+
| `bracketed_enclosure`
73+
| `braced_enclosure`
74+
parenthesized_enclosure:
7875
| `group`
7976
| `tuple`
8077
| `yield_atom`
8178
| `generator_expression`
79+
bracketed_enclosure:
8280
| `listcomp`
8381
| `list`
82+
braced_enclosure:
8483
| `dictcomp`
8584
| `dict`
8685
| `setcomp`
@@ -111,6 +110,13 @@ Evaluation of these atoms yields the corresponding value.
111110
^^^^^
112111
SyntaxError: cannot assign to False
113112
113+
Formally, the syntax for built-in constants is:
114+
115+
.. grammar-snippet::
116+
:group: python-grammar
117+
118+
builtin_constant: 'True' | 'False' | 'None' | '...'
119+
114120
.. _atom-identifiers:
115121

116122
Identifiers (Names)
@@ -657,9 +663,9 @@ The formal grammar for dict displays is:
657663
Comprehensions
658664
--------------
659665

660-
List, set and dictionary :dfn:`comprehensions` are a form of :ref:`displays`
661-
where items are computed via a set of looping and filtering instructions
662-
rather than listed explicitly.
666+
List, set and dictionary :dfn:`comprehensions` are a form of
667+
:ref:`container displays <displays>` where items are computed via a set of
668+
looping and filtering instructions rather than listed explicitly.
663669

664670
In its simplest form, a comprehension consists of a single expression
665671
followed by a :keyword:`!for` clause.
@@ -755,8 +761,8 @@ that start with `f` is::
755761
['fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum']
756762

757763
At run time, the expression after :keyword:`!if` is evaluated before
758-
each element is added to the resulting container.
759-
If the expression evaluates to false, the element is skipped.
764+
each element is added to the resulting container, and if it is false,
765+
the element is skipped.
760766
Thus, the above example roughly corresponds to defining and calling the
761767
following function::
762768

@@ -778,7 +784,7 @@ See the next section for a more formal description.
778784
Complex comprehensions
779785
^^^^^^^^^^^^^^^^^^^^^^
780786

781-
Generally, a comprehension's initial :keyword:`!for` clause may be followed
787+
Generally, a comprehension's initial :keyword:`!for` clause may be followed by
782788
zero or more additional :keyword:`!for` or :keyword:`!if` clauses.
783789
For example, here is a list of names exposed by two Python modules,
784790
filtered to only include names that start with ``a``::

0 commit comments

Comments
 (0)