is there a more pythonic way to call a generator (one that may or may not terminate) a specific number of times?
for example: if i want to call endless exaclty N = 7 times i could to it this way:
from itertools import count, accumulate
N = 7
endless = accumulate(count())
for _, out in zip(range(N), endless):
print(out)
what i do not like about that is that it is a bit error-prone (changing the order of range and the generator will call the generator N+1 times) and that i need to handle the output from range (which i do with the _ variable).