Initial thrashing about question...embedding Python

Mark Hammond MHammond at skippinet.com.au
Tue Sep 7 20:49:30 EDT 1999


Owen F. Ransen wrote in message <37d7ad42.1540192 at news.newsguy.com>...
>If I embed Python in a Windows app which does not
>have a text output screen, where does all the printed
>output go?

As for normal Python, it goes to whereever sys.stdout or sys.stderr is
pointing.  In most GUI apps, this goes nowhere until you explicitely change
it.  Pythonwin for example simply defines an instance with a "write" method,
and sets sys.stderr and sys.stdout to that.  This class instance then
manages writing it to the GUI window.

In the sort term (ie, while developing) you may find the win32 module
"win32traceutil" useful - add this as the first line of Python code
executed, and all output will be redirected to another process (you can see
the output by running win32traceutil as a script in another process).
Again, this is what I use for Pythonwin when I manage to break its startup
code during development - at least I can see the tracebacks that prevent my
real object from being instantiated.

Mark.







More information about the Python-list mailing list