Multi-line input reader
There's not much code, however, I'd change input_lines in the following ways:



  Only display prompt while reading first line.


If you're only going to do something once, then just add it as an initial return.
It's simpler IMO to have a try that wraps the entire code of the function, this way you know it will keep doing something until EOFError is raised. Rather than possibly do something on each iteration.

As noted in the comments by OP, you can instead use contextlib.suppress, which can make the code easier to read.
You may want to use yield from and iter, if you think that's cleaner to read than a while loop.


This can result in either of:

def input_lines(prompt=None):
    try:
        if prompt is not None:
            yield input(prompt)
        while True:
            yield input()
    except EOFError:
        pass




from contextlib import suppress


def input_lines(prompt=None):
    with suppress(EOFError):
        if prompt is not None:
            yield input(prompt)
        yield from iter(input, None)