[Python-Dev] accumulator display syntax

Michael Chermside mcherm at mcherm.com
Tue Oct 21 16:38:33 EDT 2003


Skip writes:
> thought the definition for list comprehension syntax was something like
> 
>     '['
>         <expr> for <vars> in <expr>
>                [ for <vars> in <expr> ] *
>                [ if <expr> ] *
>     ']'

Nope:

>>> [x*y for x in 'aBcD' if x.islower() for y in range(4) if y%2]
['a', 'aaa', 'c', 'ccc']

-- Michael Chermside




More information about the Python-Dev mailing list