> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# HOW TO : Clear screen based on OS in python scripts
- URL: https://kudithipudi.org/how-to-clear-screen-based-on-os-in-python-scripts/
- Published: 2012-03-08T14:59:46.000Z
- Updated: 2012-03-08T14:59:46.000Z
- Description: I like shiny new toys :). Even though perl is pretty powerful and more than enough for the simple tasks I get to automate from time...
- Author: admin
- Tags: HOWTO, Programming, Technology, Uncategorized, #wp, #wp-post, #Import 2026-08-23 02:32

I like shiny new toys :). Even though [perl](http://perl.org/?ref=kudithipudi.org) is pretty powerful and more than enough for the simple tasks I get to automate from time to time, I want to start learning [python](http://python.org/?ref=kudithipudi.org) and find out first hand, why the whole geek community is raving about it.

As I start to write new scripts in python, I wanted to document how I used to do some things in perl and how I implemented them in python.

One of the standard features of any script I write is to “clear” the screen before starting to send output to the console. Here is the comparison between perl and python

#### perl

```
system $^O eq ‘MSWin32’ ? ‘cls’ : ‘clear’;
```

#### python

```

# Clear screen, based on the OS
if (os.name == ‘nt’):
os.system("cls")
else:
os.system("clear")

```