preventing creation of instance
koenig at v-i-t.de
Wed Jun 18 01:05:51 CEST 2003
I have a class with a 'static' list of names to control if every instance
of the class has a different name.
names = 
def __init__( self, name ):
Is it possible to chech in init if the given name exists in names and
then destroy itself. So that it will be not possible to create an
instance of this class, if the given name is existing.
adam = test( "adam" ) # should work
eve = test ( "adam" ) #should then not work. eve should be None.
More information about the Python-list