[y for y in (f(x) for x in l) if y]
Will do.
More Related Contents:
- how to create a list of lists using list comprehension [closed]
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- Flattening a shallow list in Python [duplicate]
- List comprehension vs map
- Is it Pythonic to use list comprehensions for just side effects?
- Generator expressions vs. list comprehensions
- List comprehension rebinds names even after scope of comprehension. Is this right?
- Creating a dictionary from a csv file?
- How do I create a list of lambdas (in a list comprehension/for loop)?
- Double Iteration in List Comprehension
- List comprehension vs generator expression’s weird timeit results?
- List vs generator comprehension speed with join function [duplicate]
- How can I do assignments in a list comprehension?
- Comprehension for flattening a sequence of sequences? [duplicate]
- How can I use a conditional expression (expression with if and else) in a list comprehension? [duplicate]
- `elif` in list comprehension conditionals
- How to return a subset of a list that matches a condition [duplicate]
- The truth value of an array with more than one element is ambigous when trying to index an array
- Why list comprehension is much faster than numpy for multiplying arrays?
- How to set local variable in list comprehension?
- Too many if statements
- Comprehension on a nested iterables?
- remove None value from a list without removing the 0 value
- `if key in dict` vs. `try/except` – which is more readable idiom?
- Flattening a list of NumPy arrays?
- How to remove duplicate items from a list using list comprehension? [duplicate]
- sum each value in a list of tuples
- flatten list of list through list comprehension
- Converting List Comprehensions to For Loops in Python
- Optimal method to find the max of sublist items within list