Dlaczego działa ten wzorzec Pythona Borg / Singleton

po prostu natknąłem się na sieć i znalazłem te interesujące kody wycięte:

http://code.activestate.com/recipes/66531/

class Borg:
    __shared_state = {}
    def __init__(self):
        self.__dict__ = self.__shared_state
    # and whatever else you want in your class -- that's all!

Rozumiem, czym jest singleton, ale nie rozumiem tego kodu. Czy mógłbyś mi wyjaśnić, jak / gdzie „__shared_state” w ogóle się zmienił?

Próbowałem tego w ipythonie:

In [1]: class Borg:
   ...:         __shared_state = {}
   ...:     def __init__(self):
   ...:             self.__dict__ = self.__shared_state
   ...:     # and whatever else you want in your class -- that's all!
   ...: 
In [2]: b1 = Borg()
In [3]: b2 = Borg()
In [4]: b1.foo="123"
In [5]: b2.foo
Out[5]: '123'
In [6]: 

ale nie w pełni rozumiem, jak to się mogło stać.

questionAnswers(3)

yourAnswerToTheQuestion