Embedded python 'scripting engine' inside Python app

Patrick Stinson patrickkidd at gmail.com
Sun Nov 23 00:48:18 EST 2014


I am writing a python app (using PyQt, but that’s not important here), and want my users to be able to write their own scripts to automate the app’s functioning using an engine API hat I expose. I have extensive experience doing this in a C++ app with the CPython api, but have no idea how to do this outside of calling exec() from with in Python :)

Ideally their script would compile when the source changes and retain it’s state and respond to callbacks from the api object. It appears this won’t work with exec() because the script’s definitions and state disappear as soon as the exec() call is complete, and the script doesn’t seem to be able to access it’s own defined functions and classes.

Thoughts? Fun stuff!

Thanks!


More information about the Python-list mailing list