Can "self" crush itself?
n00m
n00m at narod.ru
Tue Nov 24 23:57:04 EST 2009
Why does "h" instance stay alive?
class Moo:
cnt = 0
def __init__(self, x):
self.x = x
self.__class__.cnt += 1
if self.__class__.cnt > 2:
self.crush_me()
def crush_me(self):
print 'Will self be crushed?'
self = None
f = Moo(1)
g = Moo(2)
h = Moo(3)
print f
print g
print h
=============== RESTART ====
Will self be crushed?
<__main__.Moo instance at 0x00CC9260>
<__main__.Moo instance at 0x00CC9468>
<__main__.Moo instance at 0x00CC94B8>
More information about the Python-list
mailing list