[Tutor] Clear Screen

Allan Crooks allan.crooks@btinternet.com
Fri, 27 Jul 2001 23:10:12 +0100


Hi,

> I was hoping there would be some way to change >>>cls() to simply >>>cls -
> but this is close enough! :)

It just occured to me how you could do this.

class clear:
    
    def __repr__(self):
        import os, sys
        cls = os.popen("clear").read()
        sys.stdout.write(cls)
        return ""

cls = clear()

Now you can type cls, and it'll run the clear.__repr__ method, which will in turn clear the screen for you. :)

Allan.