Benjamin Rutt wrote: […]
Thanks.� I'm having trouble integrating this or Andrew's idea into my example.� The simplest case doesn't quite work right for me (I see '>>>' prompts, and can interact with the python interpreter but the banner appears at the end of the REPL after I press Ctrl+D, and then I never see the '>' prompts from my original program anymore)...was this what you had in mind?� See the diff below.
What I had in mind was that you not use the 'code' module directly at all: the manhole module already implements the intergration you are looking for (and more). e.g. what happens if you replace “stdio.StandardIO(Echo())” in your original example with this: from twisted.conch import manhole stdio.StandardIO(manhole.Manhole()) I certainly didn't mean to suggest assigning a StandardIO instance to sys.stderr; it doesn't implement Python's file-like object protocol, so it will fail to do anything useful in that context. -Andrew.