[Python-ideas] Suggestion: Clear screen command for the REPL

Paul Moore p.f.moore at gmail.com
Mon Sep 19 09:12:48 EDT 2016


On 19 September 2016 at 13:10, Paul Moore <p.f.moore at gmail.com> wrote:
>
> For this particular suggestion, though, I don't think that's the case.
> I think it's going to either be something that's accepted into the
> stdlib, or something that's rejected as too platform-specific or messy
> to standardise, and people should roll their own implementation.

Note, by the way, that in the form of a Python function, this
capability is already available in lots of places - colorama and click
include it, for a start. And even the stdlib has a version in the
curses module (albeit not available on Windows).

In the light of this, there seems little reason to water down this
proposal to "provide a clear screen function in the stdlib".

Taken in its original form of "add a command to the REPL to clear the
screen", the main issue is that the standard Python REPL simply
doesn't have a concept of "REPL commands", so there's nowhere really
to add that functionality without a relatively major overhaul. People
who want a richer REPL can look at other options like IDLE, or
IPython/Jupyter.

By the way - if you're on a system with readline support included with
Python, GNU readline apparently has a binding for clear-screen
(CTRL-L) so you may well have this functionality already (I don;'t use
Unix or readline, so I can't comment for sure).

So the proposal becomes limited to:

"""
Add a capability to the standard REPL to recognise and support
"commands" (as distinct from executable Python code) and provide a
"clear screen" command.
"""

This feature is only needed for users of the standard Python REPL, on
systems without readline support (i.e. Windows). I don't think that's
a significant enough benefit to warrant the change (even if we take
into account the potential opportunity for additional commands that
we'd get from adding command support to the REPL).

Paul


More information about the Python-ideas mailing list