Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python how to tell if class is initialized

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #class #initialized
ADD COMMENT
Topic
Name
9+8 =