Re: [Tutor] flyweight pattern using Mixin vs. Inheritance

2009-08-28 Thread Serdar Tumgoren
class A: > instances = {} > def __new__(self,ID): > if ID in self.instances: > return self.instances[ID] > else: > self.instances[ID] = self > return self > def __init__(self, ID): > if ID not in self.instances: > print("unregistered instance!") > def __del__(self): > del(self.instances[self.I

Re: [Tutor] flyweight pattern using Mixin vs. Inheritance

2009-08-28 Thread Serdar Tumgoren
I was able to resolve the error by explicitly naming the class in the dictionary lookup inside __new__: if candid in CandidateAuto.instances: return candid I'm curious why this is necessary though. From our earlier dicussions (and from other reading), I thought that by declari

Re: [Tutor] flyweight pattern using Mixin vs. Inheritance

2009-08-28 Thread Alan Gauld
"Serdar Tumgoren" wrote Given those requirements, is the Mixin approach the way to go? Either way, have I implemented these correctly? I haven't looked at your code but you could use a mixin here however I find using mixins for insantiation can bend your brain. I tend to use them for instan