Skip to content

Instantly share code, notes, and snippets.

@4e1e0603
Last active December 4, 2015 12:37
Show Gist options
  • Save 4e1e0603/0e57d8f90e17793f584e to your computer and use it in GitHub Desktop.
Save 4e1e0603/0e57d8f90e17793f584e to your computer and use it in GitHub Desktop.
Clear the Python interpreter screen

Clear the screen with the running Python interpreter.

...as a function

def clear_screen(): import os; os.system('cls' if os.name=='nt' else 'clear')

...as a lambda expression with explicit import statement

import os
clear_screen = lambda: import os; os.system('cls' if os.name=='nt' else 'clear') or None

...without explicit import statement

clear_screen = lambda: __import__('os').system('cls' if __import__('os').name=='nt' else 'clear') or None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment