title: exec python2 vs python3
body: <p>I'm transferring a testframework from python2 to python3.
  I have troubles with the exec statement to exec function change.
  At run-time I decide depending on a xls file which function is called.
  I tried to give local() and global() and also tried the execHelper instead of exec (see example below) I also tried the namespace technique of the exechelper function direct in the testfunction but always some names are not found in the namespace....
  any suggestions?</p>
  
  <pre><code>def execHelper(command,callerobject):
      ns = {}
      exec(command,ns)
      for name, value in ns.items():
          setattr(callerobject, name, value)
  
  def myfunction2(val1,val2):
      return val1 * val2
  
  class myclass():
      def myfunction1(self,val1,val2):
          return val1 + val2
  
      def test(self):
          a = 5
          self.b = 10
          exec("result = self.myfunction1(a,self.b)+myfunction2(a,self.b)")
          print(result)
  
  
  test = myclass()
  test.test()
  </code></pre>