Running python apps from within python apps

Claudio Grondi claudio.grondi at freenet.de
Sat Jan 14 10:24:19 EST 2006


aph wrote:
> Hello. I'm sure this has been asked before, but I can't find an answer
> anywhere.
> 
> I want to create a truly "dynamic" app which can get new functions
> "on-the-fly" and run them without having to re-start the main app.
> 
> I've found the code module that looks kind of hopefull. For instance
> this works great:
> 
> import code
> 
> class myApp:
> 
>     def __init__(self):
>         self.ii = code.InteractiveInterpreter()
> 
>     def kalle(self,str):
>         return str.upper()
> 
>     def run_script(self,script):
>         self.ii.runsource(script)
> 
> app = myApp()
> app.run_script("print 'hello'")
> 
> Now I want this new script to interact with the existing program, and
> it doesn't work. I cant for instance do:
> 
> app.run_script("print self.kalle('hello')")
> 
> Any tips of how to make this work? Is it possible?
> 
I have no idea what do you want to achieve and have no experience with 
PyPy myself, but I mean, that what you want to achieve should be 
possible using it :

http://codespeak.net/pypy/dist/pypy/doc/getting-started.html

Claudio



More information about the Python-list mailing list