Giampaolo Rodola' <[email protected]> added the comment:
What I would do:
- build the namedtuple in Python rather than in C
- I don't particularly like CamelCased names for nametuples (I would use "size"
instead of "TerminalSize")
- on UNIX, the ioctl() stuff can be done in python rather than in C
- use C only on Windows to deal with GetStdHandle/GetConsoleScreenBufferInfo;
function name should be accessed as nt._get_terminal_size similarly to what we
did for shutil.disk_usage in issue12442.
- do not raise NotImplementedError; if the required underlying functions are
not available os.get_terminal_size should not exists in the first place (same
as we did for shutil.disk_usage / issue12442)
Also, I'm not sure I like fallback=(80, 25) as default, followed by:
try:
size = query_terminal_size(sys.__stdout__.fileno())
except OSError:
size = TerminalSize(fallback)
That means we're never going to get an exception.
Instead I would:
- provide fallback as None
- let OSError propate unless fallback is not None
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13609>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com