[Tutor] Fixing garbled email addresses

Alan Gauld alan.gauld at btinternet.com
Tue May 1 17:03:03 CEST 2007

"Dotan Cohen" <dotancohen at gmail.com> wrote 

> Does 'list comprehension' mean a detailed explanation of the code? 

No its a programming construct found in Function programming 
languages such as Haskell (Python is partially functional in nature).

Basically a list comprehension builds a list

lc = [item_expression for item in collection if item_test]

This is equivalent to

lc = []
for item in collection:
    if item_expression:

But it's shorter and usually faster.

See the functional programming topic of my web tutor for more 
info and examples.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list