I have a lazy generator which I want to take N items and put them in a list. Is there any concise way (Akin to list comprehension style) without using for loop and manually appending each item to a list?
My question is different than the duplicate one proposed because it involves generators (And you cannot slice generators) and has a condition which has to be satisfied.
This is what I'm doing now:
my_list = []
counter = 0
for item in my_generator():
if counter == 10:
break
if condition(item):
my_list.append(item)
counter += 1