Message 152394 - Python tracker (original) (raw)

Well, right now it's just one function. Functionality which you propose could of course be useful, but let's leave if for another day, another issue.

See also http://bugs.python.org/issue13609#msg149627 and #444582 and #12442 -- shutil is growing in different directions, and terminal size can be one of them.

Antoine Pitrou added the comment: "except Exception" clauses in the tests are too broad. Fixed. Otherwise, looks fine.

STINNER Victor added the comment:

Hum, you may document the default value: (80, 24). Done.

shutil.get_terminal_size() is tied to COLUMNS and ROWS and thus makes most sense for stdout. But I guess that an optional parameter could be added: shutil.get_terminal_size(fd=None, fallback=(80, 24)) where fd could be either an integer, or an object with .fileno(). I don't know.

Thanks for the review and comments!

Patch version nine attached: termsize.diff.8