From ccd3bf72c05c057b9eadb16035c7afd5796c6303 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 31 Aug 2021 19:22:50 -0700 Subject: [PATCH] Add gentools.run. --- voussoirkit/gentools.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/voussoirkit/gentools.py b/voussoirkit/gentools.py index c271640..1f48472 100644 --- a/voussoirkit/gentools.py +++ b/voussoirkit/gentools.py @@ -13,3 +13,11 @@ def chunk_generator(sequence, chunk_length): if not chunk: break yield chunk + +def run(g) -> None: + ''' + Iterate the generator and discard the results. Used when the generator has + side effects that are more important than the yielded values. + ''' + for x in g: + pass