On Sat, Oct 17, 2020 at 5:23 PM Eryk Sun <eryk...@gmail.com> wrote:

> I'd prefer shutil.clear_screen(). There's already
> shutil.get_terminal_size(). I know there's also
> os.get_terminal_size(), but its use isn't encouraged.
>

then how about os.clear_terminal() ?

after all, this will not clear the "screen", by pretty much any
modern definition of screen.

I am curious though -- is there any hope of writing even a 90% solution
across all platforms that matter?

This seems to be very much a function of the terminal program, not the
operating system.

Sure, there's a manageable set of default terminals across the major OSs
(and lInux Desktops), but there are a LOT of others as well, including
IDEs, and even the new Terminal in Windows:

https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701?rtc=1&activetab=pivot:overviewtab

(which I haven't tried yet -- no handy Windows Box at the moment)

Anyway -- this is an honest question -- I have no idea if there is enough
standardization to make it possible, but maybe someone on this thread does.

-CHB

PS: I use the built in Terminal app on OS-X: cmd+K clears the screen and
scrollback buffer. clearclears the screen, but not the scrollback buffer. I
found this on SO:

https://superuser.com/questions/243693/how-to-reset-teminal-under-mac-os-x-programmatically

which involved calling osascript -- I tried it, and got a dialog asking for
permission for Terminal to access System Events, and then it failed with an
error:

System Events got an error: osascript is not allowed to send keystrokes.

I only spent five minutes on it -- but not straightforward.




-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4MXECRH73LFDSBMHIAWP64UFSOBPWM3W/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to