On Sat, Jan 28, 2017 at 7:03 PM, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > But if I pipe the output to something else, the shutil version fails to > determine the correct terminal size, and falls back on the default: > > > [steve@ando ~]$ python3.5 test_gts.py | cat > shutil: os.terminal_size(columns=999, lines=999) > os: os.terminal_size(columns=116, lines=29) > > > while the os version gives the correct result.
I believe the problem here is your definition of "correct". When you inquire of the os module, you're asking, at a fairly low level, what the terminal window is sized to. But when you ask shutil, you're asking what a shell utility should do. Quite a few programs change in behaviour when piped into something else (for instance, 'ls' will often apply colour and columnate its text, but if you pipe it into grep, you don't want any of that), and shutil is acknowledging that different effect. Both are correct answers - to different questions. ChrisA -- https://mail.python.org/mailman/listinfo/python-list