On Mon, Jun 29, 2009 at 12:17 PM, Gertjan Klein <gkl...@xs4all.nl> wrote:

> Tim Roberts wrote:
>
> >Gertjan Klein wrote:
>  >> 2) I see print statements in the source code, but I have no idea where
> >> they go; I checked the event log, but they are not there. Are they
> >> logged anywhere? If not, why are they there to begin with?
> >>
> >> Any other tip on how to effectively debug this stuff would be most
> >> welcome as well.
> >
> >The print statements go into empty space because there is no stdout for
> >that process.  You can try using the logging module to log to a file, or
> >you can use ctypes to write to kernel32.OutputDebugString and using a
> >kernel debug log monitor to read them.
>
> The logging module reminds me of Java too much. :(  I think I'll try to
> write to a file, I have no idea if I have a kernel debug log monitor.
>
>  <http://mail.python.org/mailman/listinfo/python-win32>
>

sys.stdout works like a normal Python file, so you should be able to assign
a new file object to it.

You might try something like:
--------------
>>> x = open('x.txt','w')
>>> import sys
>>> sys.stdout = x
>>> print 'hello, world'
>>> exit()

C:\Users\vernon>type x.txt
hello, world
-----------
For debugging, you may want to add
sys.stderr = x
as well.
--
Vernon Cole
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to