1import os
2
3def clearConsole():
4 command = 'clear'
5 if os.name in ('nt', 'dos'): # If Machine is running on Windows, use cls
6 command = 'cls'
7 os.system(command)
8
9clearConsole()
10
1As you mentioned, you can do a system call:
2
3For Windows
4>>> import os
5>>> clear = lambda: os.system('cls')
6>>> clear()
7
8For Linux the lambda becomes
9>>> clear = lambda: os.system('clear')