On 14.10.2020 00:35, Guido van Rossum wrote:
> Can one of the educators on the list explain why this is such a commonly
> required feature? I literally never feel the need to clear my screen -- but 
> I've
> seen this requested quite a few times in various forms, often as a bug report
> "IDLE does not support CLS". I presume that this is a common thing in other
> programming environments for beginners -- even C++ (given that it was
> mentioned). Maybe it's a thing that command-line users on Windows are told to 
> do
> frequently? What am I missing that students want to do frequently? Is it a
> holdover from the DOS age?

I often use clear or Ctrl-L in terminals when I'm preparing demos
or screensharing.

Given that we already have os.get_terminal_size(), perhaps adding
a helper os.clear_terminal() would make sense, along the lines of

https://man7.org/linux/man-pages/man1/clear.1.html

I don't remember ever having a need for this in Python, though. When
I do have such needs to drive the terminal to get e.g. bold output,
I usually use ANSI escape codes:

https://en.wikipedia.org/wiki/ANSI_escape_code

but then I normally write scripts for Unix, not other platforms, so
perhaps having a cross-platform variant would be useful.

In dialog driven scripts, it does make sense to clear the screen to
get attention from the user for requesting input. This was also
standard when terminals were being used as the main UI for applications
in the vt100 days. I guess today, most people use the endless
scrolling approach, so it's less comon and where it is
needed, you have ncursus or other terminal UI managers take care
of this for you.

> On Tue, Oct 13, 2020 at 11:25 AM Mike Miller <python-id...@mgmiller.net
> <mailto:python-id...@mgmiller.net>> wrote:
> 
> 
>     On 2020-10-13 06:19, Stestagg wrote:
>     > For example, the pypi `console` library provides a method:
>     `console.sc.reset()`
>     > that behaves similarly to `CLS` on windows and also appears to be fairly
>     > reliable cross-platform.
> 
> 
>     Yes, there is more to it than appears at first glance.  There is 
> resetting the
>     terminal, clearing the currently visible screen, and/or the scrollback
>     buffer as
>     well.
> 
>     The legacy Windows console has another limitation in that I don't believe 
> it
>     has
>     a single API call to clear the whole thing.  One must iterate over the 
> whole
>     buffer and write spaces to each cell, or some similar craziness.  That's 
> why
>     even folks writing C++ just punt and do a system("cls") instead.
> 
>     With the mentioned lib console, the example above prints the ANSI codes 
> to do a
>     terminal reset, and while that works widely these days, it should not be 
> the
>     first choice.  It would be better to use the cross-platform wrapper
>     functions in
>     the console.utils module, either:
> 
>          # A DOS-like reset, clears screen and scrollback, also aliased to 
> cls()
>          reset_terminal()
> 
>          # A Unix-like clear, configurable via param, and aliased to clear()
>          clear_screen()
> 
>     -Mike
>     _______________________________________________
>     Python-ideas mailing list -- python-ideas@python.org
>     <mailto:python-ideas@python.org>
>     To unsubscribe send an email to python-ideas-le...@python.org
>     <mailto: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/MX54AOXMYJHGRVOO2XW3J7JWHQDDUKPQ/
>     Code of Conduct: http://python.org/psf/codeofconduct/
> 
> 
> 
> -- 
> --Guido van Rossum (python.org/~guido <http://python.org/~guido>)
> /Pronouns: he/him //(why is my pronoun here?)/
> <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
> 
> _______________________________________________
> 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/J65P6UELD4RSSCSMAFYF52WADURHX2HL/
> Code of Conduct: http://python.org/psf/codeofconduct/
> 

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Oct 14 2020)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/
_______________________________________________
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/AV6NAZIARPGLTVDXGIXQLYEIFJ6RNPBS/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to