For clearing screen in the shell for OS X, you can use the subprocess module and call 'cls' from the shell:-
import subprocess as sp sp.call('cls',shell=True)
For the window you can use the following:-
tmp = sp.call('cls',shell=True)
For Linux, you must replace cls command with clear
tmp = sp.call('clear',shell=True)
To know more about this you can have a look at the following video tutorial:-