title: How to run "exec" from the global scope in python
body: <p>I have a Class. In that class I have a function.
  In the function, I have a string variable that holds definitions of several python functions.</p>
  
  <p>I would like <strong>from the function</strong> to create the functions that are defined in the variable, such that they will be created in the <strong>global scope</strong>.</p>
  
  <p>After this operation, I would like to be able to call to the new function from the global scope.</p>
  
  <p>For example:</p>
  
  <pre><code>class MyClass:
    def create_functions():
     functions_to_create = """
  def glob1():
    return "G1"
  
  def glob2():
    return "G2"
  """
     # ----&gt; HERE IS THE MISSING PART, LIKE RUNNING exec in the global scope &lt;----
  
  
  # The following function should work:
  def other_function_in_global_scope():
    print "glob1: %s, glob2: %s" % (glob1(), glob2())
  </code></pre>
  
  <p>What should be in the MISSING PART?</p>
  
  <p>Thanks in advance!!!</p>