title: How to load variables from file in Python
body: <p>Say there's a variable </p>
  
  <pre><code>x = "/real/path/"
  </code></pre>
  
  <p>inside a text file "setting.txt", and in a config xml file "config.xml" contains a tag </p>
  
  <pre><code>&lt;root&gt;    
      &lt;setting&gt;setting.txt&lt;/setting&gt; 
      ......
  &lt;/root&gt;
  </code></pre>
  
  <p>In my Python script test.py, I would like to do this:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  import os
  
  x = "/path/placeholder"    
  
  def load_global_setting_from_config_xml(in_xml):
      tree = ET.parse(in_xml)
      root = tree.getroot()
      config_node = root.find("setting")
      if config_node is not None:
          config_file_path = config_node.text
          if os.path.exists(config_file_path):
             execfile(config_file_path) # looks not working
  
  load_global_setting_from_config_xml("config.xml")
  print(x) #expected output is /real/path
  </code></pre>
  
  <p>it looks execfile() does not working.</p>