I'm having problems implementing a borg in python. I found an example in an answer to this question but it's not working for me, unless I'm missing something. Here's the code:
class Config:
"""
Borg singleton config object
"""
__we_are_one = {}
__myvalue = ""
def __init__(self):
#implement the borg pattern (we are one)
self.__dict__ = self.__we_are_one
self.__myvalue = ""
def myvalue(self, value=None):
if value:
self.__myvalue = value
return self.__myvalue
conf = Config()
conf.myvalue("Hello")
conf2 = Config()
print conf2.myvalue()
I assume this is meant to print "Hello", but for me it just prints a blank line. Any ideas why this might be?