title: Edit & save dictionary in another python file
body: <p>I have 2 python files, file1.py has only 1 dictionary and I would like to read &amp; write to that dictionary from file2.py. Both files are in same directory.</p>
  
  <p>I'm able to read from it using <strong>import file1</strong> but how do I write to that file.</p>
  
  <p>Snippet:</p>
  
  <p>file1.py (nothing additional in file1, apart from following data)</p>
  
  <pre><code>dict1 = {
          'a' : 1,      # value is integer
          'b' : '5xy',   # value is string
          'c' : '10xy',
          'd' : '1xy',
          'e' : 10,
          }
  </code></pre>
  
  <p>file2.py</p>
  
  <pre><code>    import file1
      import json
  
      print file1.dict1['a']    #this works fine
      print file1.dict1['b']
  
      # Now I want to update the value of a &amp; b, something like this:
  
      dict2 = json.loads(data)
      file1.dict1['a'] = dict2.['some_int']     #int value
      file1.dict1['b'] = dict2.['some_str']     #string value
  </code></pre>
  
  <p>The main reason why I'm using dictionary and not text file, is because the new values to be updated come from a json data and converting it to a dictionary is simpler saving me from string parsing each time I want to update the <strong>dict1</strong>.</p>
  
  <p>Problem is, <strong>When I update the value from dict2, I want those value to be written to dict1 in file1</strong></p>
  
  <p>Also, the code runs on a Raspberry Pi and I've SSH into it using Ubuntu machine.</p>
  
  <p>Can someone please help me how to do this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <ol>
  <li>file1.py could be saved in any other format like .json or .txt. It was just my assumption that saving data as a dictionary in separate file would allow easy update.</li>
  <li>file1.py has to be a separate file, it is a configuration file so I don't want to merge it to my main file.</li>
  <li>The <strong>data</strong> for <strong>dict2</strong> mention above comes from socket connection at</li>
  </ol>
  
  <p><code>dict2 = json.loads(data)</code></p>
  
  <ol start="4">
  <li>I want to update the *file1** with the data that comes from socket connection.</li>
  </ol>