i just stumbled around the net and found these interesting code snipped:
http://code.activestate.com/recipes/66531/
class Borg:
__shared_state = {}
The instances are separate objects, but by setting their __dict__
attributes to the same value, the instances have the same attribute dictionary. Python uses the attribute dictionary to store all attributes on an object, so in effect the two instances will behave the same way because every change to their attributes is made to the shared attribute dictionary.
However, the objects will still compare unequal if using is
to test equality (shallow equality), since they are still distinct instances (much like individual Borg drones, which share their thoughts but are physically distinct).