Misuse of list comprehensions?

Diez B. Roggisch deets at nospam.web.de
Tue May 20 09:51:17 EDT 2008


bearophileHUGS at lycos.com wrote:

> John Salerno:
>> What does everyone think about this?
> 
> The Example 2 builds a list, that is then thrown away. It's just a
> waste of memory (and time).

No, it doesn't. It uses append because it refers to itself in the
if-expression. So the append(c) is needed - and thus the assignment
possible but essentially useless.

Diez



More information about the Python-list mailing list