Resetting generator object in Python
Generators can’t be rewound. You have the following options: Run the generator function again, restarting the generation: y = FunctionWithYield() for x in y: print(x) y = FunctionWithYield() for x in y: print(x) Store the generator results in a data structure on memory or disk which you can iterate over again: y = list(FunctionWithYield()) for … Read more