get the terminal's size

Bob van der Poel bob at mellowood.ca
Mon Jan 14 13:08:06 EST 2019


On Mon, Jan 14, 2019 at 4:57 AM Alex Ternaute <alex at lussinan.invalid> wrote:

> Hi there,
>
> I want to know the number of columns of the terminal where python2 writes
> it's outputs.
>
> In a terminal, I type
> $ echo $COLUMNS
> 100
>
> But in Python, os.getenv("COLUMNS") gets nothing.
> It gets nothing as well if I try to read the output of "echo $COLUMNS"
> from a subprocess.
>
> I feel that I'm missing something but what ?
>
> Looking on the internet for a hint, I see that python3 has an
> os.get_terminal_size().
> Please, is there something similar for python2 ?
>
> Cheers
> --
> Alex
> --
> https://mail.python.org/mailman/listinfo/python-list
>

try this:


http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python


-- 

**** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bob at mellowood.ca
WWW:   http://www.mellowood.ca



More information about the Python-list mailing list