class MyList(list):
def __new__(cls, *p, **k):
if not '_the_instance' in cls.__dict__:
cls._the_instance = list.__new__(cls)
return cls._the_instance
def append(self, name):
if name not in self:
list.append(self, name)
def extend(self, names):
for name in names:
if name in self:
continue
list.append(self, name)
def remove(self, name):
if name in self:
list.remove(self, name)
def clear(self):
del self[:]
I was trying to make a singleton instance... but im guessing it doesn't work because lists are mutable. I know i could use a decorator but im stuck using 2.5 and not 2.6 =( ... Anyone have any ideas?