Silly question: I have a simple for loop followed by a simple if statement:
for airport in airports: if airport.is_important:
and
Using list comprehension (only if airports is a list of objects):
for airport in [a for a in airports if a.is_important]:
Mabe this, but it's more or less the same verbose...
import itertools for airport in itertools.ifilter(lambda x: x.is_important, airports): ...