[issue13609] Add "os.get_terminal_size()" function
STINNER Victor
report at bugs.python.org
Tue Jan 31 16:03:28 CET 2012
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
termsize.diff.7:
- shutil.get_terminal_size(): I would prefer columns and lines
variable names instead of "ccc" and "rrr"
- "Right now the values are not cached, but this might change." why
would it be cached? this sentence can just be removed
- I would prefer os.get_terminal_size() instead of
os.query_terminal_size(), I didn't know other function using the verb
"query" in Python
- To keep os simple, os.query_terminal_size() can return a simple,
whereas shutil.get_terminal_size() returns a namedtuple
- test_os.py: use @unittest.skipUnless() on TermsizeTests to check if
os.query_terminal_size() is available
- test.py, test_does_not_crash() catchs OSError, you may only ignore
some error codes, not any. For example, skip the test if stdout is not
a tty
+ try:
+ size = os.query_terminal_size(sys.__stdout__.fileno())
+ except (NameError, OSError):
+ size = os.terminal_size(fallback)
AttributeError should be catched here, not NameError. Or better, check
if os has a query_terminal_size() function.
+.. function:: get_terminal_size(fallback=(columns, lines))
Hum, you may document the default value: (80, 24).
shutil.get_terminal_size() doesn't allow to choose the file
descriptor. Would it be useful to allow to get the size of sys.stderr
or another TTY?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13609>
_______________________________________
More information about the Python-bugs-list
mailing list