By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

How to clear screen in Python interactive shell mode?

P: n/a
In Python interactive mode, is there some function acting like 'clear'
command in bash? Could somebody here give some advice?

Thanks in advance.

Sep 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
A. L. wrote:
In Python interactive mode, is there some function acting like 'clear'
command in bash? Could somebody here give some advice?

Under Linux/UNIX system (on x86 at least) you can use the CTRL+L
combination to clear the screen.
I do not now similar for Windows and MACs.

Les

Sep 16 '05 #2

P: n/a
Thank you very much. I have tested it under Cygwin, and that works. But
it fails under Windows Python Shell Mode.

Sep 16 '05 #3

P: n/a
On Thu, 15 Sep 2005 21:18:33 -0700, A. L. wrote:
In Python interactive mode, is there some function acting like 'clear'
command in bash? Could somebody here give some advice?

Thanks in advance.

Something like this may help:

def clearscreen(numlines=100):
"""Clear the console.

numlines is an optional argument used only as a fall-back.
"""
import os
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')
else:
# Fallback for other operating systems.
print '\n' * numlines
--
Steven.

Sep 16 '05 #4

P: n/a
I have tested it under windows python console, and it works.

Thank you very much.

Sep 16 '05 #5

P: n/a
elif os.name in ("nt", "dos", "ce"):
# emacs/Windows
What`s the right statement here?

Sep 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.