Can "self" crush itself?

n00m n00m at narod.ru
Wed Nov 25 04:46:29 EST 2009


Then how can we destroy the 3rd instance,
right after its creation and from inside
class Moo code?

class Moo:
    cnt = 0
    def __init__(self, x):
        self.x = x
        self.__class__.cnt += 1
        if self.__class__.cnt > 2:
            print id(self)
            ## 13406816
            ## in what dict is this ID?
            ## and can we delete it from there?

            ## ???


f = Moo(1)
g = Moo(2)
h = Moo(3)
print h




More information about the Python-list mailing list