[Tutor] Re: clear screen [Let's make a feature request in Sourceforge!]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat Nov 16 15:21:01 2002


On Thu, 14 Nov 2002 lumbricus@gmx.net wrote:

> > class _cls:
> >     def __init__(self):
> >         if sys.platform in ('linux-i386', 'linux2'):
> >             self._command = 'clear'
>
> There are more UNICES than Linux. As I wrote in an earlier post IMHO
> os.name is the better choice, because it just spits out 'posix' for all
> the different UNICES out there.

Yikes!  Thanks for pointing that out.  Ok, that's something I'll can fix.

But I'm getting the feeling that this is a reimplementation of the
platform-detection code that must exist somewhere in the 'distutils'
though.  I should take a closer look at it to see if I can dodge this
whole platform-detection issue altogether... *grin*



> > I can't confirm that it works on Win32 yet; can someone check this?
> > Once it checks out ok, we can submit this to Python's sourceforge as a
> > feature request.  Who knows?  It might get in...
>
> IMHO clearing the screen at the beginning of a console program is a bad
> habit. You loose information and gain nothing.


I understand what you mean.  But the same time, though, I have fond
memories of writing small games in Basic that used to clear the screen
quite a bit!  Memory card games, for example, are all about obscuring
information.

For very simple programs (especially games), being able to clear the
screen would be helpful:  it would allow beginners to write those kind of
primitive user interfaces that we know are evil and crude, but are really
easy to cook up.

If 'curses' were more platform independent and less difficult to use for
newcomers, this would be a nonissue; curses and its erase() method would
be the right solution to clearing the console.

But I feel that 'curses' has a complicated feel to it, and curses doesn't
quite work out-of-the-box with Python on Windows systems yet.  (I might be
wrong about that last comment; does anyone know if the cygwin port works
better at this?)



Thanks for your help!