From e0771afa7727c8a14705de1f68d2fed1c515a747 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 14 Jan 2021 02:37:04 -0800 Subject: [PATCH] Add input_many. --- voussoirkit/pipeable.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/voussoirkit/pipeable.py b/voussoirkit/pipeable.py index 10915d2..b7598d9 100644 --- a/voussoirkit/pipeable.py +++ b/voussoirkit/pipeable.py @@ -131,6 +131,17 @@ def input( continue yield line +def input_many(args, *input_args, **input_kwargs): + ''' + Given many input arguments, yield the input() results for all of them. + This saves you from having to write the double for loop yourself. + ''' + if isinstance(args, str): + args = [args] + + for arg in args: + yield from input(arg, *input_args, **input_kwargs) + def _output(stream, line, end): line = str(line) stream.write(line)