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

Steven D'Aprano steve at pearwood.info
Tue Sep 20 09:31:18 EDT 2016


On Mon, Sep 19, 2016 at 06:18:38AM -0400, Terry Reedy wrote:
> On 9/19/2016 4:31 AM, Paul Moore wrote:
> 
> >shutil.get_terminal_size() is available on all platforms.
> 
> On windows, it works with Command Prompt and PowerShell but fails in 
> IDLE, as it must.

Why "must" it fail?

What is it about the IDLE terminal that prevents it from emulating an 
actual terminal, like all(?) the other terminal emulation programs 
people use?

I just opened my Konqueror file & web browser, gave the command "Show 
Terminal Emulator", and ran Python:

py> import shutil
py> shutil.get_terminal_size()
os.terminal_size(columns=85, lines=10)

That's spot on perfectly correct. I then resized the window and tried it 
again:

py> shutil.get_terminal_size()
os.terminal_size(columns=108, lines=13)


I then quit Python, and ran idle3.3 from the Konqueror terminal. 
Unfortunately, get_terminal_size() returned the size of the *Konqueror* 
terminal, instead of the IDLE terminal. I think that's a bug. I don't 
know if its a bug in IDLE or get_terminal_size() or both.


-- 
Steve


More information about the Python-ideas mailing list