[Tutor] Clear Screen

Andrei Kulakov ak@silmarill.org
Fri, 27 Jul 2001 04:22:50 -0400


On Thu, Jul 26, 2001 at 10:51:59PM -0400, fleet@teachout.org wrote:
> >Date: Thu, 26 Jul 2001 18:45:13 +0200
> >From: Kalle Svensson <kalle@gnupung.net>
> >
> >Why eval?  eval() takes a string argument and evaluates it as a python
> >expression.  Most often, the output of the system "clear" command isn't a
> >valid python expression... <wink>
> >My guess is that you really want
> >
> >def clear():
> >    import os, sys
> >    cls = os.popen("clear").read()
> >    sys.stdout.write(cls)
> 
> This works!
> 
> >or, perhaps even better
> >
> >def clear():
> >    import os
> >    os.system("clear")
> 
> This works like *my* clear() function works - leaves two lines at the top
> of the screen. ??

Humm, that's odd.. Well, if you run it like that in an interpreter, it does
print out return value (0), you may get rid of it by doing throw_away = os.system('clear'). In a script, os.system('clear') shouldn't leave any lines at the top, and in fact I'm using it in my mp3 player cymbaline (plug, plug!), url in my sig, and it works great.

[snip]

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline