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

Paul Moore p.f.moore at gmail.com
Mon Sep 19 04:31:11 EDT 2016


On 19 September 2016 at 03:40, Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> (The fallback if all else fails is easy: get the height of the terminal,
>> in lines, and print that many blank lines.)
>
> Assuming you can get the height in lines. Have you tried that in the
> default Windows shell? I don't think tcgetattr works on Windows.

shutil.get_terminal_size() is available on all platforms.

I don't think it would be unreasonable to add shutil.clear_terminal()
(at the moment, get_terminal_size is the only "terminal handling"
function in shutil, but it would be the obvious place to add others if
we chose to do so).

Paul


More information about the Python-ideas mailing list