|Python Language Reference Manual|
by Guido van Rossum and Fred L. Drake, Jr.
Paperback (6"x9"), 120 pages
RRP £12.95 ($19.95)
Sales of this book support the Python Software Foundation! Get a printed copy>>>
5.2.4 List displays
A list display is a possibly empty series of expressions enclosed in square brackets:
test)* [ "," ]
list_display "[" [
| ( ","
expression)* [ "," ] )
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 at least one
for clause and zero or
if clauses. In this
case, the elements of the new list are those that would be produced
by considering each of the
if clauses a block,
left to right, and evaluating the expression to produce a list element
each time the innermost block is reached(10).
|ISBN 0954161785||Python Language Reference Manual||See the print edition|