Querying the size of the output terminal
Get the size of the terminal window.
For each of the two dimensions, the environment variable,
ROWS respectively, is checked. If the variable is defined and
the value is a positive integer, it is used.
ROWS is not defined, which is the common case,
the terminal connected to
sys.__stdout__ is queried.
If the terminal size cannot be successfully queried, either because
the system doesn't support querying, or because we are not
connected to a terminal, the value given in
The value returned is a named tuple of type
Return the size of the terminal window as
tuple of type terminal_size.
The optional argument
STDOUT_FILENO, or standard
output) specifies which file descriptor should be queried.
If the file descriptor is not connected to a terminal, a
get_terminal_size is the high-level function which should normally
get_terminal_size_raw is the low-level implementation.
named tuple terminal_size(tuple)
A tuple of
(columns, rows) for holding terminal window size.
Width of the terminal window in characters.
Height of the terminal window in characters.