Attaching a live interpreter to a script?

Julian Smith jules at
Tue Jan 13 10:05:28 CET 2009

On Mon, 12 Jan 2009 23:35:14 -0800 (PST)
Kannon <neokannon at> wrote:

> What I'd like to do is attach an interpreter to a program running from
> a script (I.E, not something I typed into the live interpreter). It'd
> be an awesome way to debug programs, as well as tweak parameters and
> such at runtime. Ideally, I'd like it to be something in pure python
> so I could throw it into Jython and IronPython as well. (Though, I can
> actually code Java and C#, so implementing it is something I could do
> myself, if needed.) I was thinking maybe something I could throw into
> a tkinter window or similar, but I wasn't able to find anything on how
> to pass stuff directly to the interpreter.
> Any ideas, or if this is even possible would be nice. Thanks in
> advance.

I have a few lines of code that runs a debug-server in its own thread,
listening on a socket, and exec-ing text that is sent to the socket.
The exec happens in the debug-server thread.

It's very useful - you can get a backtrace for all threads (on
python-2.5 and later), look at globals, call functions, etc etc, all
while the main programme is running.

If anyone's interested, i'll put the code somewhere. It's all very
simple; some would say crude, too.

- Jules


More information about the Python-list mailing list