GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.python.org — 5.2.4 List displays

Previous Page Up One Level Next Page Python Reference Manual Contents Index
Previous: 5.2.3 Parenthesized forms Up: 5.2 Atoms Next: 5.2.5 Dictionary displays


5.2.4 List displays

A list display is a possibly empty series of expressions enclosed in square brackets:

list_display:   "[" [listmaker] "]"
listmaker:   expression ( list_for | ( "," expression)* [","] )
list_iter:   list_for | list_if
list_for:    "for" expression_list "in" testlist [list_iter]
list_if:     "if" test [list_iter]

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 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.


Previous Page Up One Level Next Page Python Reference Manual Contents Index
Previous: 5.2.3 Parenthesized forms Up: 5.2 Atoms Next: 5.2.5 Dictionary displays

See About this document... for information on suggesting changes.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.