Website hosting and domain hosting service by Active-Venture.com
  

 Back to Index


5.2.4 List displays

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

 

test  ::=  and_test ( "or" and_test )* | lambda_form
testlist  ::=  test ( "," test )* [ "," ]
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]
Download entire grammar as text.

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.

 

  

 

2002-2004 Active-Venture.com Website Hosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Active-Domain.com offers cheap domain registration, domain name transfer and domain search services   Cheap domain name - Cheap domain name registration service including free domain hosting services  

Domain registration : Buy domain name or register domain name from $5.95/year only