class object def __init__ self self log init def log self msg sys stdo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
>>>>>>: class A(object):
...: def __init__(self):
...: self.log('init')
...: def log(self, msg):
...: sys.stdout.write(msg+'\n')
...: sys.stdout.flush()
...: def __del__(self):
...: self.log('del')
...:
...:
>>>>>>: a = A()
init
>>>>>>: del(a)
del