Here is a sample code to do it,
def func():
return something
# I want to break the list comprehension at the first None.
# The walrus := is valid in Python 3.8
items = [r for _ in range(100) if (r := func()) is not None]
# else break?
I wonder if it is possible that break in list comprehension with any method, such as takewhile or others?