Extend/embedd python problem?

Mile Blenton nomejl at blentronix.com
Thu Feb 16 07:12:35 EST 2006


Hello all,

I am considering python as a 'scripting' language to be used
in my application where users must be able to write their own 
code to access application data, use the application mechanisms
to gather various data and basicly must be able to control the 
application itself.

Currently, to accomplish this task, my app uses my custom C-like 
language and my bytecode interpreter. In this case I am able to 
control the execution of a single 'instruction' in my interpreter
and interpret the user code when I want. It also enables me to support 
multiple 'user tasks' (not a system LWP-like tasks, but a higher-level
concurrent execution simulation - each task has it's own interpreter 
and each interpreter is executed every n-th iteration for example). 

I have glanced at the python/C api ref manual and know I can
use the 'PyRun_InteractiveOne' to execute a single python 
statement, but am not sure if there's a way to 'precompile'
python code and prepare it for execution so I can interpret
the precompiled statements one-by-one, similarly to my custom
interpreter.

I noticed the 'Py_CompileString' but am not sure what to do and 
how to interact with 'PyObject*' it returns me - how do I run it, 
can I interrupt it when it's executing, can I run it on 
per-statement basis'?

Any help or pointers where to look for answers to my questions is
grately apreciated.

Thanks,
Regards,
  Mario





More information about the Python-list mailing list