title: How to define a function name using a string
body: <p>Im trying to create a more dynamic program where I define a function's name based on a variable string.</p>
  
  <p>Trying to define a function using a variable like this:</p>
  
  <pre class="lang-py prettyprint-override"><code>__func_name__ = "fun"
  
  def __func_name__():
    print('Hello from ' + __func_name__)
  
  fun()
  </code></pre>
  
  <p>Was wanting this to output:</p>
  
  <pre><code>Hello from fun
  </code></pre>
  
  <p>The only examples I found were:
  <a href="https://stackoverflow.com/questions/5920120/how-to-define-a-function-from-a-string-using-python">how to define a function from a string using python</a></p>