Re: Traceback strings
Mark Hammond (MHammond@cmutual.com.au)
Sun, 18 Sep 1994 23:43:48 GMT
In article <199409161658.AA17307@marcel.gamekeeper.bellcore.com>, "C. Derek Fields" <derek@gamekeeper.bellcore.com> says:
>
>I have embedded python into a Gui application and I want to be able to
>show exception strings similar to what the interpreter displays, but I
>want to show them in a window. Has anyone written code similar to
>print_error() that returns a traceback string instead of printing directly
>to a file?
The trick here seems to be:
* in Python code, define an object that supports the "write()" method.
FWIW, there seems to be a small problem that requires SOFTSPACE attribute
to be defined too (I cant remember exact details of the problem).
* redirect sys.stdout and sys.stderr to this object.
* call print_error, or just allow the standard traceback mechansim
to work.
Then, the output will go whereever your write() method sends it.
HTH...
Mark.