Hacker News new | ask | show | jobs
by eswoo 2901 days ago
It needs to be

    [bar(foo(y)) for y in (z for z in stuff if foo(z))]
(etc.) though, since `bar` takes as input the output of `foo`. This leads to the objectionable duplicate calls to `foo`, hence the new assignment expressions.

I like Dunnorandom's

    [bar(x) for x in map(foo, stuff) if x]
best for a correct result using existing syntax, or

    [bar(x) for y in (foo(x) for x in stuff) if y]
if you don't like `map`.