title: Configurations from file for python dictionaries and strings
body: <p>I have configurations for python script which includes integers, strings and dictionaries. A sample config.txt file is as below</p>
  
  <pre><code>mode = 'train,test,validation'
  
  pick_one_in_n_files = 2
  
  #dictionary for labels
  labels = dict(
      bowl=0,
      coffee_mug=1,
      food_bad=2,
      food_box=3,
      food_can=4,
      instant_noodles=5,
      plate=6,
      soda_can=7,
      sponge=8,
      water_bottle=9
      )
  </code></pre>
  
  <p>I am reading this text file and writing a new temporary python file with same text as in config. Then import the new python file into my script and use data from it.</p>
  
  <pre><code>configuration_import = open(config_path.replace('txt','py'),mode =       'w+')
  configuration_text = open(config_path,mode ='r')
  configuration_import.write(configuration_text.read())
  configuration_import.close()
  configuration_text.close()
  return importlib.import_module(config_path.replace('.txt',''))
  </code></pre>
  
  <p>This serves the purpose but i am looking for an elegant approach to this problem.</p>
  
  <p>This way the user will only provide a configuration text file. He will not be allowed to edit python files. Drawback is that the file has to be in python format instead of some standard yaml, json etc.</p>