[Python-ideas] Re: built in to clear terminal

2020-12-31 Thread Stephen J. Turnbull
Mike Miller writes: > Note, I added the word *important* on purpose. ;-) Ie, since you were lucky enough the time you did something like it, it's not important to anybody? > Reminds me of a story. As an teen I learned the lesson of what > happens when you flip the power switch of the comput

[Python-ideas] Re: built in to clear terminal

2020-12-29 Thread Mike Miller
On 2020-12-29 15:07, Chris Angelico wrote: On Wed, Dec 30, 2020 at 9:57 AM Mike Miller wrote: Also, I'd argue the likelihood of a newbie clearing important work... is not very high. Disputed on the basis of having seen it all too often :) Note, I added the word *important* on purpose.

[Python-ideas] Re: built in to clear terminal

2020-12-29 Thread Chris Angelico
On Wed, Dec 30, 2020 at 9:57 AM Mike Miller wrote: > Also, I'd argue the likelihood of a newbie clearing important work... is not > very high. > Disputed on the basis of having seen it all too often :) ChrisA ___ Python-ideas mailing list -- python-id

[Python-ideas] Re: built in to clear terminal

2020-12-29 Thread Mike Miller
On 2020-12-28 23:33, Stephen J. Turnbull wrote: The thing is, this is a destructive capability. In some cases it only clears the "screen" (whatever that means), which may cost you some diagnostics. Probably (but not always) you can recreate them by repeating a command from history. But in so

[Python-ideas] Re: built in to clear terminal

2020-12-28 Thread Stephen J. Turnbull
Mike Miller writes: > No offense, but if you're a developer who can't handle hotkeys or > came of age before the "glass tty" and won't learn any new tricks… > well, that's just *"your problem, mayan."* > > The rest of us are capable. :D The thing is, this is a destructive capability. In s

[Python-ideas] Re: built in to clear terminal

2020-12-28 Thread Mike Miller
On 2020-12-26 19:45, 2qdxy4rzwzuui...@potatochowder.com wrote: On 2020-12-27 at 13:24:34 +1100, Steven D'Aprano wrote: But the ctrl-L trick has no discoverability. It took me close to twenty years of using Linux before I discovered it, and I still don't remember to use it when I need it. >

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread Chris Angelico
On Sun, Dec 27, 2020 at 4:26 PM Steven D'Aprano wrote: > > On Sun, Dec 27, 2020 at 02:00:00PM +1100, Chris Angelico wrote: > > > This is actually the exact part that I think should *not* happen, for > > several reasons: > > > > 1) Stuff that exists interactively and doesn't exist in a script is a

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread Steven D'Aprano
On Sun, Dec 27, 2020 at 02:00:00PM +1100, Chris Angelico wrote: > This is actually the exact part that I think should *not* happen, for > several reasons: > > 1) Stuff that exists interactively and doesn't exist in a script is a > barrier to that migration. I don't think this feature justifies th

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread 2QdxY4RzWzUUiLuE
On 2020-12-27 at 13:24:34 +1100, Steven D'Aprano wrote: > But the ctrl-L trick has no discoverability. It took me close to > twenty years of using Linux before I discovered it, and I still don't > remember to use it when I need it. The first time a sysadmin added readline to one of our work comp

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread Chris Angelico
On Sun, Dec 27, 2020 at 1:25 PM Steven D'Aprano wrote: > But the ctrl-L trick has no discoverability. It took me close to twenty > years of using Linux before I discovered it, and I still don't remember > to use it when I need it. > > Beginners and casual users aren't going to know ctrl-L, or stum

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread Steven D'Aprano
On Sat, Dec 26, 2020 at 05:58:16PM -0800, Christopher Barker wrote: > > > > On 2020-12-22 14:01, Steven D'Aprano wrote: > > > It seems to me that the primary use for this will be in the interactive > > > interpreter. People are used to something like "cls" or "clear" from > > > various shells. Usin

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread Christopher Barker
> > On 2020-12-22 14:01, Steven D'Aprano wrote: > > It seems to me that the primary use for this will be in the interactive > > interpreter. People are used to something like "cls" or "clear" from > > various shells. Using it in scripting is, I think, a secondary use-case. > ' I disagree. yes, I wa

[Python-ideas] Re: built in to clear terminal

2020-12-26 Thread Mike Miller
On 2020-12-22 14:01, Steven D'Aprano wrote: It seems to me that the primary use for this will be in the interactive interpreter. People are used to something like "cls" or "clear" from various shells. Using it in scripting is, I think, a secondary use-case. Given that, I think that like othe

[Python-ideas] Re: built in to clear terminal

2020-12-24 Thread Ben Rudiak-Gould
On Thu, Dec 24, 2020 at 1:34 AM Barry Scott wrote: > if sys.playform == 'win32': > os.system('cls') > else: > sys.stdout.write('\x1b[2J' '\x1b[H') > > No concern about CLS being a trojan becuse as a builtin to CMD and > PowerShell > and it takes priority over cls.bat etc.

[Python-ideas] Re: built in to clear terminal

2020-12-24 Thread Barry Scott
> On 22 Dec 2020, at 12:39, Eryk Sun wrote: > > On 12/22/20, Barry Scott wrote: >> >> import sys >> >> def clear_terminal(): >>if sys.platform == 'win32': >>import ctypes >>kernel32 = ctypes.windll.kernel32 >># turn on the console ANSI colour handling >>k

[Python-ideas] Re: built in to clear terminal

2020-12-24 Thread Ben Rudiak-Gould
On Tue, Dec 22, 2020 at 4:46 PM Christopher Barker wrote: > Though, yeah shelling out to an arbitrary command on the system is a bit > scary -- does the Python stdlib currently do that anywhere? > Here's what I found by grepping the sources for uses of os.system and subprocess: * pydoc shells o

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread David Mertz
As I say, I just discovered the fact about conda vendoring `clear`. I haven't looked further into what includes it as dependency... although it seems to be in pretty much all my environments, so maybe IPython? On Wed, Dec 23, 2020 at 12:46 AM Christopher Barker wrote: > On Tue, Dec 22, 2020 at

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Eryk Sun
On 12/22/20, David Mertz wrote: > On Tue, Dec 22, 2020 at 10:26 PM Chris Angelico wrote: > > I'm not sure about Windows. Is 'cls' built into the command-line executable > itself (like Busybox) or is it an exe? CLS is an internal command of the CMD shell. An internal command takes precedence as l

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Christopher Barker
On Tue, Dec 22, 2020 at 2:58 PM David Mertz wrote: > Somewhat supporting my concern, I just was surprised to find this: > > % ll `which clear` > -rwxrwxr-x 2 dmertz 14344 Nov 14 17:07 /home/dmertz/miniconda3/bin/clear > % ll /usr/bin/clear > -rwxr-xr-x 1 root 14656 Feb 29 2020 /usr/bin/clear >

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread David Mertz
On Tue, Dec 22, 2020 at 10:26 PM Chris Angelico wrote: > A tight loop clearing the screen? If you have that, you have much > bigger problems :). But shelling out to clear/cls has another problem: > it's a big ol' > dependency. You need to have the corresponding command, and it needs > to be acces

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Chris Angelico
On Wed, Dec 23, 2020 at 9:15 AM Steven D'Aprano wrote: > > On Mon, Dec 21, 2020 at 08:22:35AM +1100, Cameron Simpson wrote: > > >is it so bad to use a subprocess? > > > > Yes. It is _really slow_, depends on external reaources which might not > > be there, and subprocess brings other burdens too.

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Steven D'Aprano
On Mon, Dec 21, 2020 at 08:22:35AM +1100, Cameron Simpson wrote: > Anyway, I think it should be in curses (or be loaded via curses on > demand), and just have a clear_screen function thus: > > def clear_screen(): > setupterm() > print(ti_getstr('cl'), end='', flush=True) [..

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Steven D'Aprano
On Sat, Dec 19, 2020 at 08:50:57PM -0800, Guido van Rossum wrote: > On Sat, Dec 19, 2020 at 7:43 PM Steven D'Aprano wrote: > > > Thread is here: > > > > > > https://mail.python.org/archives/list/python-ideas@python.org/message/EWQ2BOL3WVZAU2V2MT3HLXN3AEBHANNZ/ > > > > > > I don't think this needs

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Stephen J. Turnbull
Eryk Sun writes: > Here are some concerns I have: This is the best argument for a clear_terminal (clear_window?) builtin I've seen. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org h

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Eryk Sun
On 12/22/20, Barry Scott wrote: > > import sys > > def clear_terminal(): > if sys.platform == 'win32': > import ctypes > kernel32 = ctypes.windll.kernel32 > # turn on the console ANSI colour handling > kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) > >

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Barry Scott
> On 22 Dec 2020, at 09:49, Barry Scott wrote: > > The simplest answer is > > print('`\x1b[2J\x1b[H') > > Are there any terminals that this does not work on that are in active use? > > Is using curses that uses termcap needed these days? > > Of course Windows is the outlier, but the

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Barry Scott
The simplest answer is print('`\x1b[2J\x1b[H') Are there any terminals that this does not work on that are in active use? Is using curses that uses termcap needed these days? Of course Windows is the outlier, but the new Windows Terminal supports ANSI escapes sequences and utf-8. I tes

[Python-ideas] Re: built in to clear terminal

2020-12-21 Thread Ben Rudiak-Gould
On Sun, Dec 20, 2020 at 8:06 PM Eryk Sun wrote: > The entire buffer can be scrolled out, like > the CMD shell's CLS command, or one can just scroll the buffer enough > to clear the visible window. > The Windows console model is a bit different from POSIX terminals. Instead of having a screen and

[Python-ideas] Re: built in to clear terminal

2020-12-21 Thread Christopher Barker
On Sun, Dec 20, 2020 at 4:12 PM Cameron Simpson wrote: > Untested: > cls_bs = None > > def clear_screen(): > if cls_bs is None: > try: > import curses > except ImportError: > cls_bs=curses.tigetstr('clear') > print(cl

[Python-ideas] Re: built in to clear terminal

2020-12-20 Thread Eryk Sun
On 12/20/20, Cameron Simpson wrote: > On 20Dec2020 15:48, Christopher Barker wrote: > >>That would be great, though I just looked at the 3.9 docs and saw: >>"The Windows version of Python doesn’t include the curses module." > > Yeah, Windows. A C or ctypes implementation is required in Windows.

[Python-ideas] Re: built in to clear terminal

2020-12-20 Thread Felipe Rodrigues
well, my two cents here is that I do clear my screen - a lot. In the same use case as Guido's mentioned - exploratory programming. But when I do it, I do in a manner that was discussed in the original thread - by using CTRL+L, which is of course terminal-specific but clears everything both in Pytho

[Python-ideas] Re: built in to clear terminal

2020-12-20 Thread Cameron Simpson
On 20Dec2020 15:48, Christopher Barker wrote: >On Sun, Dec 20, 2020 at 1:23 PM Cameron Simpson wrote: >> My anger at programmes which gratuitously clear the screen is large. > >There are a LOT of bad things one can do with Python, I don't think we need >to make something difficult simply because

[Python-ideas] Re: built in to clear terminal

2020-12-20 Thread Christopher Barker
On Sun, Dec 20, 2020 at 1:23 PM Cameron Simpson wrote: > On 20Dec2020 08:51, Christopher Barker wrote: > >On Sat, Dec 19, 2020 at 8:53 PM Guido van Rossum > wrote: > >> at sounds like a very special status. Why not os.clear()? > > My anger at programmes which gratuitously clear the screen is la

[Python-ideas] Re: built in to clear terminal

2020-12-20 Thread Cameron Simpson
On 20Dec2020 08:51, Christopher Barker wrote: >On Sat, Dec 19, 2020 at 8:53 PM Guido van Rossum wrote: >> at sounds like a very special status. Why not os.clear()? My anger at programmes which gratuitously clear the screen is large. (Years of anger watching IBM-derived PCs boot, particularly,

[Python-ideas] Re: built in to clear terminal

2020-12-20 Thread Christopher Barker
On Sat, Dec 19, 2020 at 8:53 PM Guido van Rossum wrote: > at sounds like a very special status. Why not os.clear()? >> > > I do agree with the motivation for doing this. (I've started doing more > exploratory programming and I've felt this need clearly a few times.) > Frankly, you can't do hardl

[Python-ideas] Re: built in to clear terminal

2020-12-19 Thread Guido van Rossum
On Sat, Dec 19, 2020 at 7:43 PM Steven D'Aprano wrote: > Thread is here: > > > https://mail.python.org/archives/list/python-ideas@python.org/message/EWQ2BOL3WVZAU2V2MT3HLXN3AEBHANNZ/ > > > I don't think this needs to be a literal built-in, part of the > interpreter. I think it could be a library

[Python-ideas] Re: built in to clear terminal

2020-12-19 Thread Steven D'Aprano
Thread is here: https://mail.python.org/archives/list/python-ideas@python.org/message/EWQ2BOL3WVZAU2V2MT3HLXN3AEBHANNZ/ I don't think this needs to be a literal built-in, part of the interpreter. I think it could be a library function which is added to builtins on startup, like `help` and `qui