ActiveState Code

Recipe 498064: clear the screen


Clear the screen on unix terminals, uses terminfo.

terminfo inspiration courtesy of http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116

Python
1
2
3
4
5
def clear_screen():
    import curses, sys
    curses.setupterm()
    sys.stdout.write(curses.tigetstr("clear"))
    sys.stdout.flush()

Sign in to comment