list comprehension

utabintarbo utabintarbo at gmail.com
Thu Jun 29 14:00:58 EDT 2006


Simon Forman wrote:
> results = []
> for var in some_iterable:
>     if some condition:
>         results.append(some expression)
>
>
> The list comprehension version:
>
> results = [some expression for var in some_iterable if some condition]
>
>
> There's more to it, but that's the basic idea.

Even if 'a' doesn't like it, I do! :-)




More information about the Python-list mailing list