summaryrefslogtreecommitdiffstats
path: root/Doc/ref
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/ref')
-rw-r--r--Doc/ref/ref5.tex19
1 files changed, 14 insertions, 5 deletions
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex
index db98fe4..6b699bc 100644
--- a/Doc/ref/ref5.tex
+++ b/Doc/ref/ref5.tex
@@ -152,13 +152,22 @@ A list display is a possibly empty series of expressions enclosed in
square brackets:
\begin{verbatim}
-list_display: "[" [expression_list] "]"
+list_display: "[" [expression_list [list_iter]] "]"
+list_iter: list_for | list_if
+list_for: "for" expression_list "in" testlist [list_iter]
+list_if: "if" test [list_iter]
\end{verbatim}
-A list display yields a new list object. If it has no expression
-list, the list object has no items. Otherwise, the elements of the
-expression list are evaluated from left to right and inserted in the
-list object in that order.
+A list display yields a new list object. Its contents are specified
+by providing either a list of expressions or a list comprehension.
+When a comma-separated list of expressions is supplied, its elements are
+evaluated from left to right and placed into the list object in that
+order. When a list comprehension is supplied, it consists of a
+single expression followed by one or more "for" or "if" clauses. In this
+case, the elements of the new list are those that would be produced
+by considering each of the "for" or "if" clauses a block, nesting from
+left to right, and evaluating the expression to produce a list element
+each time the innermost block is reached.
\obindex{list}
\indexii{empty}{list}