python how to tell if class is initialized

32

class Test :
    count = 0
    def __init__(self, value) :
        if self.__class__.count > 0 :
            raise Exception
        else :
            self.__class__.count += 1
            self.value = value          #for the sake of the example


t1 = Test(12)      #instantiates the object
t2 = Test(27)      #throws an error

Comments

Submit
0 Comments