3 ms·
I use this function to force evaluation of elements in a generator: def do(gen): for x in gen: pass It evaluates all elements of a genera
by omaranto 13y ago
I use this function to force evaluation of elements in a generator:
def do(gen):
for x in gen:
pass
It evaluates all elements of a generator with storing them in memory. If you don't mind generating some garbage, you can just use the list function instead.