Add input_many.
This commit is contained in:
parent
6666430ed8
commit
e0771afa77
1 changed files with 11 additions and 0 deletions
|
@ -131,6 +131,17 @@ def input(
|
||||||
continue
|
continue
|
||||||
yield line
|
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):
|
def _output(stream, line, end):
|
||||||
line = str(line)
|
line = str(line)
|
||||||
stream.write(line)
|
stream.write(line)
|
||||||
|
|
Loading…
Reference in a new issue