"For" loop and list comprehension similarity

s.lipnevich at gmail.com s.lipnevich at gmail.com
Mon Mar 27 15:04:00 CEST 2006

I think I like generator comprehension in this case better than either
list comprehension or a filter because both of the latter create a new
full "result list" before the loop even begins. At least I suppose they
do. Also, I think Mitja's suggestion "if not <test>: continue" and
Terry's filter function are more readable than comprehensions.
It's not a contest though :-), all these variants are great, thank you
Do you think this discussion is a proof that the following principle
got violated, or do you think that "loop with condition" is not such an
atomic thing to be subject to this: "There should be one -- and
preferably only one -- obvious way to do it."


More information about the Python-list mailing list