[Python-ideas] 'where' statement in Python?
Sturla Molden
sturla at molden.no
Tue Jul 20 21:57:02 CEST 2010
> [x for x in another_list if y < 5 where y = f(x)]
> [x for (x,y) in map(lambda x: (x,f(x)), another_list) if y < 5]
Or allow nested list comprehensions?
[x for (x,y) in [x,f(x) for x in another_list] if y < 5]
this is getting closer to LINQ...
We could use line-breaks for readability:
[x for (x,y) in
[x,f(x) for x in another_list]
if y < 5]
S.
More information about the Python-ideas
mailing list