Python object cache
I tried a bit of code but it seems to cause issues: class Page: cache = [] """ Return cached object """ def __getCache(self, title): for o in Page.cache: if o.__searchTerm == title or o.title == title: return o return None """ Initilize the class and start processing """ def __init__(self, title, api=None): o = self.__getCache(title) if o: self = o return Page.cache.append(self) # Other init code self.__searchTerm = title self.title = self.someFunction(title) Then I try: a = Page('test') b = Page('test') print a.title # works print b.title # AttributeError: Page instance has no attribute