title: reformatting strings with included variables
body: <p>I have a library full of variables(that I do not wish to hand edit), it looks like this:</p>
  
  <pre><code>def get_variables(gateway):
      variables={
          'gateway':gateway, 
          'license_test_data':gateway['license_data'],
          'license_for_application':gateway['license_for_application'],
          'Valid_Login_Test_Vairables':{'valid_ssh_command':['ssh '+gateway['DeviceUnderTestUserid']+'@'+gateway['DeviceUnderTestIP'],'password:']}
          #around 3000 more just like this or worse
         }
  return variables
  </code></pre>
  
  <p>I need to import this information into a python data structure <em>without replacing the 'gateway' variables</em>.  In other words I want to be able to:</p>
  
  <pre><code>print vars['Valid_Login_Test_Vairables']['valid_ssh_command']
  </code></pre>
  
  <p>and get exactly this</p>
  
  <pre><code>'ssh +gateway['DeviceUnderTestUserid']+'@'+gateway['DeviceUnderTestIP'],'password:']
  </code></pre>
  
  <p>Instead I end up with this:</p>
  
  <pre><code>print vars['Valid_Login_Test_Vairables']['valid_ssh_command']
  
  "ssh gateway['DeviceUnderTestUserid']@gateway['DeviceUnderTestIP']", 'password:'
  </code></pre>
  
  <p>What I have been trying is this:</p>
  
  <pre><code>import varfile
  import dummy.gateway
  vars=varfile.get_variables(dummy.gateway)
  </code></pre>
  
  <p>with my dummy.gateway looking like this:</p>
  
  <pre><code>gateway['license_test_data'] = "gateway['license_test_data']"
  gateway['license_for_application'] = "gateway['license_for_application']"
  gateway['license_for_setup'] = "gateway['license_for_setup']"
  </code></pre>
  
  <p>What can I do to get the exact contents of my variable file into a useful data structure?</p>