title: How to set a variable by its name in Python?
body: <p>EDIT 2 : since so many people are crying against the bad design this usecase can reveal. Readers of these question and answers should think twice before using it</p>
  
  <p>I've trying to set a variable (not property) by it's name in Python :</p>
  
  <pre><code>foo = 'bar'
  thefunctionimlookingfor('foo', 'baz')
  print foot #should print baz
  </code></pre>
  
  <p>PS : the function to access a variable by its name (without eval) would be a plus !</p>
  
  <p>EDIT : I do know dictionary exists, this kind of usage is discouraged, I've choose to use it for a very specific purpose (config file modification according to environment), that will let my code easier to read.</p>