Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sys.settrace() and stopping the Python interpreter

1 view
Skip to first unread message

Francis Joanis

unread,
Jun 2, 2003, 7:47:36 AM6/2/03
to
Hello everyone,

I am relatively new to Python and I am looking forward to embed it
under a C++ application (gcc/linux) to add scripting capability.

I've seen various posts about being able or not to stop the execution
of a running Python script based on whatever conditions.

From what I've seen there is no built-in ways of doing this directly
as a Python feature since it was not designed/implemented.

On the other hand, I've experimented with the sys.settrace function
(in order to do some condition checking then to raise an exception to
stop the interpreter) but from what I've seen, setting up a trace
function won't take care of Python's built in functions (like
'print').

I'd like to know if there is a way to set a trace function to process
every instructions?

Thanks,

Francis Joanis

Peter Hansen

unread,
Jun 2, 2003, 7:54:49 AM6/2/03
to

settrace() *does* execute for every instruction - every Python
bytecode instruction. The problem is that print is *not* a
function (even if you unnecessarily use parentheses with it)
but rather an actual bytecode instruction. As far as I know,
there is no way for you to break print down into any component
instructions to trace, because there are none.

-Peter

0 new messages