> On Mon, 14 Jan 2019 11:57:33 +, Alex Ternaute wrote:
>
> > Hi there,
> >
> > I want to know the number of columns of the terminal where python2 writes
> > it's outputs.
A couple days late to the party, a discussion of several ways I tried:
On Mon, 14 Jan 2019 11:57:33 +, Alex Ternaute 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
On 2019-01-16, Karen Shaeffer wrote:
[fixed quoting and formatting]
>> That will tell you the terminal size at the time Python was started.
>>
>> If the terminal size has changed while Python was running, those
>> environment variables will be wrong. You need to use the TIOCGWINSZ
>> ioctl
That will tell you the terminal size at the time Python was started.
If the terminal size has changed while Python was running, those
environment variables will be wrong. You need to use the TIOCGWINSZ
ioctl call:
http://www.delorie.com/djgpp/doc/libc/libc_495.html
And to detect the
On 15Jan2019 13:08, Alex Ternaute wrote:
I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE,
universal_newlines=True) and it runs fine too, so the output seems not
really related to that fd.
But it is! stty(1) fetches the terminal settings from its standard
input, so "fd" is used to
Hi Cameron,
>>I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE,
>>universal_newlines=True) and it runs fine too, so the output seems not
>>really related to that fd.
> But it is! stty(1) fetches the terminal settings from its standard
> input, so "fd" is used to supply this. In your
On 15Jan2019 10:26, Alex Ternaute wrote:
My cs.tty module (on PyPI) has a ttysize function:
https://pypi.org/project/cs.tty/
which just parses the output of the stty command.
[...]
Fine, indeed ! I've installed cs.ttyy.
I just don't understand the reason why it takes "fd" as an argument.
Hi thereĀ :
> On 2019-01-14, Bob van der Poel wrote:
>> http://stackoverflow.com/questions/566746/how-to-get-console-window-
width-in-python
Simple and direct, I think I'll use this one.
Thanks a lot.
John Doe :
> and have a look at this one too:
>
Hi Cameron,
> My cs.tty module (on PyPI) has a ttysize function:
> https://pypi.org/project/cs.tty/
> which just parses the output of the stty command.
> If you don't want the cs.tty module, the ttysize code is just this:
>
> WinSize = namedtuple('WinSize', 'rows columns')
>
> def
On 1/14/19, Schachner, Joseph wrote:
> I just tested the fix I proposed, in Python 2.7.13
>
> Code:
> from win32api import GetSystemMetrics
>
> def main():
> print "Width =", GetSystemMetrics(0)
> print "Height =", GetSystemMetrics(1)
That gets the monitor size, i.e:
SM_CXSCREEN (0)
On 2019-01-14, Bob van der Poel wrote:
> try this:
>
>
> http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python
>
and have a look at this one too:
https://stackoverflow.com/questions/1396820/apt-like-column-output-python-library/1446973#1446973
>
--
On 14Jan2019 17:16, Alex Ternaute wrote:
Looking on the internet for a hint, I see that python3 has an
os.get_terminal_size().
Use that then.
Up to now I wanted to keep compatibility with a big bunch of code in
Python2 that I do no maintain by myself.
Well, I saw that get_terminal_size()
On Mon, Jan 14, 2019 at 4:57 AM Alex Ternaute 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
al Message-
From: Alex Ternaute
Sent: Monday, January 14, 2019 6:58 AM
To: python-list@python.org
Subject: get the terminal's size
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
On 2019-01-14, Schachner, Joseph wrote:
> Note sure why you couldn't capture $ echo $COLUMNS from a subprocess
> call.
You can. But, the subprocess is going to inherit the value from the
Python program's environment, so it's just pointless complexity.
--
Grant Edwards
naute
Sent: Monday, January 14, 2019 6:58 AM
To: python-list@python.org
Subject: get the terminal's size
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")
Hi,
Grant Edwards :
>>export COLUMNS LINES
> That will tell you the terminal size at the time Python was started.
Ok, I think tracking these changes in real time is not worth the work to
be done using Python2.
I think at last I'll rewrite this (little) programe in Python3 in order to
use
Hi Thomas
>> Looking on the internet for a hint, I see that python3 has an
>> os.get_terminal_size().
> Use that then.
Up to now I wanted to keep compatibility with a big bunch of code in
Python2 that I do no maintain by myself.
Well, I saw that get_terminal_size() follows the windows
On 2019-01-14, Peter Otten <__pete...@web.de> wrote:
> Grant Edwards wrote:
>
> os.environ["COLUMNS"]
>
>> [...] will tell you the terminal size at the time Python was started.
>
> I admit that none of my scripts is ambitious enough to try and track
> changes in terminal size.
>
> But still,
Grant Edwards wrote:
os.environ["COLUMNS"]
> [...] will tell you the terminal size at the time Python was started.
I admit that none of my scripts is ambitious enough to try and track changes
in terminal size.
But still, Grant's post prompted me to reread the doc and source of
On 2019-01-14, Peter Otten <__pete...@web.de> wrote:
>
>> 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
On 14/01/2019 12.57, Alex Ternaute 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
Hi,
Peter Otten :
>> In a terminal, I type $ echo $COLUMNS 100
>> But in Python, os.getenv("COLUMNS") gets nothing.
>> I feel that I'm missing something but what ?
> $ export COLUMNS
Thank you very much !
--
Aelx
--
https://mail.python.org/mailman/listinfo/python-list
Alex Ternaute 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
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
25 matches
Mail list logo