Help with Borg design Pattern

Casey McGinty casey.mcginty at
Sat Jun 28 03:21:39 CEST 2008


I'm trying to implement a simple Borg or Singleton pattern for a class that
inherits from 'dict'. Can someone point out why this code does not work?

class MyDict( dict ):
   __state = {}
   def __init__(self):
      self.__dict__ = self.__state

a = MyDict()
a['one'] = 1
a['two'] = 2

print a
print MyDict()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list