Share options between class instances in python
<p>Why dictionary content shared between class instances, but strings not shared?</p>

<p>Test code:</p>

<pre><code>class Config(object):
    file_names  = dict()
    file_name_1 = None
    file_name_2 = None

    def __init__(self):
        if not self.file_names:
            print "DEBUG: Config(): set initial values"
            self.file_names["0"] = None
            self.file_names["1"] = None

    def set_file_names(self, file_names):
        self.file_name_1     = file_names[0]
        self.file_names["0"] = file_names[0]
        self.file_name_2     = file_names[1]
        self.file_names["1"] = file_names[1]

class CommandLineParser(object):
    def __init__(self):
        self.cfg = Config()
        self.start()

    def start(self):
        self.cfg.set_file_names(("file_1.log", "file_2.log"))
        print self.__class__.__name__, "FileName1 (str) :", self.cfg.file_name_1
        print self.__class__.__name__, "FileName1 (dict):", self.cfg.file_names["0"]

class LogProcessor(object):
    def __init__(self):
        self.cfg   = Config()
        self.cmdln = CommandLineParser()
        print  self.__class__.__name__, "FileName1 (str) :", self.cfg.file_name_1
        print  self.__class__.__name__, "FileName1 (dict):", self.cfg.file_names["0"]

if __name__ == '__main__':
    processor = LogProcessor()
</code></pre>

<p>Output:</p>

<pre><code>DEBUG: Config(): set initial values
CommandLineParser FileName1 (str) : file_1.log
CommandLineParser FileName1 (dict): file_1.log
LogProcessor FileName1 (str) : None
LogProcessor FileName1 (dict): file_1.log
</code></pre>

<p>Is it a right way to share options between instances in dictionary attribute?</p>
