How to clear the interpreter console? How to clear the interpreter console? python python

How to clear the interpreter console?


As you mentioned, you can do a system call:

For Windows:

>>> import os>>> clear = lambda: os.system('cls')>>> clear()

For Linux it would be:

>>> import os>>> clear = lambda: os.system('clear')>>> clear()


here something handy that is a little more cross-platform

import osdef cls():    os.system('cls' if os.name=='nt' else 'clear')# now, to clear the screencls()


Well, here's a quick hack:

>>> clear = "\n" * 100>>> print clear>>> ...do some other stuff...>>> print clear

Or to save some typing, put this file in your python search path:

# wiper.pyclass Wipe(object):    def __repr__(self):        return '\n'*1000wipe = Wipe()

Then you can do this from the interpreter all you like :)

>>> from wiper import wipe>>> wipe>>> wipe>>> wipe


matomo