[Tutor] flyweight pattern using Mixin vs. Inheritance

Serdar Tumgoren zstumgoren at gmail.com
Fri Aug 28 21:20:26 CEST 2009


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 declaring a static class
attribute, that it would automatically become available to an
instances of that class. My impression was that that a method
searches for the variables/attributes in it's local scope, and failing
to find it there, would bubble up to the class level and find the
static variable there.

Is that not correct?


More information about the Tutor mailing list