Clearing screen in Python using curses?

Hi guys,

I've got the following code for clearing the screen in my Python shell using curses:

import curses 

scrn = curses.initscr() 
scrn.clear() 

However, upon execution, my shell crashes. Would appreciate a pointer in the right direction. Thanks. :smiley:

if you are using bash try this
import os
os.system("clear")

Thanks for that but I was looking to make it work independent of the shell.

vidyadhar IMHO the problem is not clear. When we initscr() there is a call to tcsetattr() to change terminal attributes (termios). The real problem is that he's not calling endwin() when he terminates his program.

import curses

scrn = curses.initscr()
scrn.clear()
curses.endwin()

Got it working great. Thanks for that guys, overlooked the fact that I had to endwin().