Is shutil.get_terminal_size useless?

Michael Torrie torriem at
Sat Jan 28 11:22:24 EST 2017

On 01/28/2017 09:03 AM, Michael Torrie wrote:
> On 01/28/2017 04:00 AM, Steve D'Aprano wrote:
>>> $ COLUMNS=123 python3 | cat
>>> shutil: os.terminal_size(columns=123, lines=999)
>>> os: os.terminal_size(columns=72, lines=48)
> Interesting. On my machine with Python 3.4, calling
> os.get_terminal_size() and piping the output results in the exception
> OSError: [Errno 25] Inappropriate ioctl for device

Oh I see you are calling get_terminal_size() on file handle 0 which is
standard in.  Generally, I can't think of very many use cases for caring
about the terminal size on the *input* side. Most times I only care
about the output side, which if it's a pipe doesn't make a lot of sense
to care about, other than maximum line length.

More information about the Python-list mailing list