The core expression is similar to this:

**y = (f(x) for x in L if f(x) is not None)**

There are a lot of variations on the filter. The point is that the function appears twice in the above expression.

We have a number of alternatives.

**y = filter(None, f(x) for x in L)**

y = filter(None, map(f, L))

y = filter(None, map(f, L))

**y = (x for x in map(f, L) if x)**

**y = (x for x in (f(y) for y in L) if x is not None)**

**y = (val for x in L for val in (f(x),) if val is not None)**

My preference is two steps, even though I don't really have a good reason for this.

**y1 = (f(x) for x in L)**

y2 = (f for f in y1 if f)

y2 = (f for f in y1 if f)

## {{ parent.title || parent.header.title}}

## {{ parent.tldr }}

## {{ parent.linkDescription }}

{{ parent.urlSource.name }}