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. Using it in scripting is, I think, a secondary use-case.
> >
> '
> I disagree. yes, I want to clear the screen a lot during interactive use,
> but I'd rather do that with a keystroke (cmd+K on the Mac) -- and indeed,
> do that with iPython all the time, even though iPython has the command
> built in.

And nobody is going to take that away from you, unless you choose to go 
to Windows, where ctrl-L doesn't work.

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 stumble 
across it through experimentation. People like me aren't going to 
remember to use it. For interactive use, os.clear is barely any better.

(Me, I'll be looking in shutils, not os, because this is a shell 
feature, not an os feature.)


> So I think the reason to have it in the std lib is for scripting, and I
> think putting it in os or sys is just fine.

Putting it in sys requires it to be built into the interpreter, which 
means it has to be written in C (for CPython). Putting it in os is fine, 
that can easily delegate to platform specific code in posix.py, nt.py 
etc, with a pure-Python lowest common denominator fallback for weird 
platforms that don't support anything sensible.

I just want site.py to import it at startup for the sake of beginners. 
Is that so bad? It adds one line to site.py, four if you want to make it 
conditional:

    try:
        from os import clear
    except:
        pass

I can easily add it to my own personal PYTHONSTARTUP file, but the 
average beginner can't. Let's throw newbies a bone and pre-import it for 
them, they're the ones who seem to expect it the most.

So that's the easy part: just agree with me and import it in site.py, 
wherever it happens to come from. *wink*

The hard part is deciding exactly what it should do, e.g. clear the 
scrollback or not. I think Chris makes a good point that real beginners 
will misuse this to hide the evidence whenever they get an error, so I 
think the default should be to *not* clear the scrollback, for the sake 
of educators, teachers and trainers. People who know what the scrollback 
is and definitely want to clear it can just provide an extra argument to 
the function.

So let's just all agree I'm right *wink* and move on to the *really* 
hard part, which is ensuring it works on Windows and weird terminals.



-- 
Steve
_______________________________________________
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/RAU2WORPY2E7IVPYBWM76YXSG43KACAE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to