Controlling Python

nriedlin at my-deja.com nriedlin at my-deja.com
Mon Aug 16 09:25:46 EDT 1999


Hi all,

in my application (written in C++) I want to use Python as the
scripting language. The application comunicates with the hardware and
when a specific event occurres, a thread is started, in which a python
interpreter is created to execute a certain script. The thread should
have a finer control over the Python-Interpreter as is possible with
PyRun_SimpleFile().
(E.g. I want to be able to stop the thread independent of the
interpreter) I would like to have some kind of "hook" after, say, every
line of python-code.
I thought something like (pseudocode):
while(getline(f, s) {
  PyRun_SimpleString(s);
  my_hook(s, lineno++,...);
}
should work but it fails, whenever the python-code becomes a little
more difficult. E.g. PyRunSimpleString() failes, whenever the simple
string continues in the following line:
if bla:
    pass

Is this the way to go? If yes: how? If no: why not and in which
direction should I turn?

Any hints are most welcom.

TIA

Norbert Riedlin


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list