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>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to