On Fri, 15 Feb 2008 11:55:11 +0800, Marco wrote: > Hi, I wanna write a simple curses program, but somethings confuse > me, my code here: > > #!/usr/bin/python > > import os > import sys > import time > import curses > > class CursesObject( object ): > > def __init__(self): > > self.STDSCR = curses.initscr() > curses.noecho() > curses.cbreak() > self.STDSCR.keypad(1) > > def __del__(self): > self.STDSCR.keypad(0) > curses.nocbreak() > curses.echo() > curses.endwin() > > c1 = CursesObject() > time.sleep(1) > > > I donot know what happen, but in __del__ function, curses become None??!!
When the interpreter shuts down it has to remove objects. Everything you need in a `__del__()` method must be referenced by that object to be sure that it is still there and not already garbage collected. *But* it's not guaranteed that `__del__()` is called at all! So if you think this clean up is necessary to leave a usable console then don't put it into a `__del__()` method! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list