actually 'exec()' is the function I was looking for. Working code: class myApp: def kalle(self,str): return str.upper() def run_script(self,script): exec(script) app = myApp() app.run_script("print self.kalle('hello')") Thanks...