title: Python: YAML dictionary of functions: how to load without converting to strings
body: <p>I have a YAML config file, which contains a dictionary, like so: </p>
  
  <pre><code>"COLUMN_NAME": column_function
  </code></pre>
  
  <p>It maps strings to functions (which exist and are supposed to be called). </p>
  
  <p>However, when I load it using <code>yaml</code>, I see that the loaded dictionary now maps strings to strings: </p>
  
  <pre><code>'COLUMN_NAME': 'column_function' 
  </code></pre>
  
  <p>Now I cannot use it as intended - <code>'column_function'</code> doesn't point to <code>column_function</code>. </p>
  
  <p>What would be a good way to load my <code>dict</code> so that it maps to my functions? After searching and reading a bit on this issue, I'm very cautious about using <code>eval</code> or something like that, since the config file is user-edited. </p>
  
  <p>I think <a href="https://stackoverflow.com/questions/295058/convert-a-string-to-preexisting-variable-names">this thread</a> is about my issue, but I'm not sure on the best way to approach it. </p>
  
  <ul>
  <li><code>getattr</code> and <code>setattr</code> are out, I think, because they operate on instantiated objects, whereas I have a simple script. </li>
  <li><code>globals()</code>, <code>vars()</code> and <code>locals()</code> provide me with <code>dict</code>s of variables, and I suppose I should use <code>globals()</code>, according to <a href="https://stackoverflow.com/a/7969953/2143578">this</a>. </li>
  </ul>
  
  <p>Should I look up the string in them for each of key-value pairs in my config <code>dict</code>? Is this a good way: </p>
  
  <pre><code>for (key, val) in STRING_DICTIONARY.items():
      try: 
          STRING_DICTIONARY[key] = globals()[val]   
      except KeyError:
          print("The config file specifies a function \"" + val 
                 + "\" for column \"" + key 
                 + "\". No such function is defined, however. ")
  </code></pre>