[Tutor] Clearing the Console Screen

Don Parris webdev at matheteuo.org
Thu Jun 16 18:27:18 CEST 2005

On Thu, 16 Jun 2005 11:16:37 -0400
Kent Johnson <kent37 at tds.net> wrote:

> Don Parris wrote:
> > With the console-based menu system I'm building, I'd like to clear the
> > screen for each menu call - something like:
> > 
> > def main_menu():
> >     clear #start with a fresh console screen, menu at top
> >     print menuitems
> There is no nice portable way to do this. On Windows running in a DOS
> window (not in IDLE or another GUI environment) you can use import os
> os.system('cls')
> Kent
> _______________________________________________

Thanks!  I thought there had to be a way to call the OS' clear screen
command, but was going about it the wrong way.  I was trying to use
sys.clear instead of os.system.  Would it be difficult to test the OS,
store the result in a variable, and call the comand based on the variable
result?  Or would it be simpler to have users edit the script for their OS?

Mind you, there may be other areas where I need an OS-specific command.  I'm
beginning to get an idea of the challenges of portability though. ;)

evangelinux    GNU Evangelist
http://matheteuo.org/                   http://chaddb.sourceforge.net/
"Free software is like God's love - you can share it with anyone anytime

More information about the Tutor mailing list