PythonWin Question

John Q. Public at home.com
Sat Dec 23 00:58:10 EST 2000


While trying to add a journaling mechanism to python, I came across an
odd behavior from PythonWin when I tried to override sys.stdout.  For
both the console and IDLE versions of the interpreter, I can override
sys.stdout, but not for PythonWin.

IDLE:

>>> import journal
>>> sys.stdout
<PyShell.PseudoFile instance at 01028F9C>
>>> journal.Open("My_Journal.txt")
>>> sys.stdout
<journal.Journal instance at 010388CC>
>>> journal.Close()
>>> sys.stdout
<PyShell.PseudoFile instance at 01028F9C>

console:

>>> import journal
>>> sys.stdout
<open file '<stdout>', mode 'w' at 00762C80>
>>> journal.Open("My_Journal.txt")
>>> sys.stdout
<journal.Journal instance at 0079285C>
>>> journal.Close()
>>> sys.stdout
<open file '<stdout>', mode 'w' at 00762C80>

PythonWin:

>>> import journal
>>> sys.stdout
<pywin.framework.interact.InteractiveView instance at 0114E01C>
>>> journal.Open("My_Journal.txt")
>>> sys.stdout
<pywin.framework.interact.InteractiveView instance at 0114E01C>
>>> journal.Close()
No open journals!
>>> sys.stdout
<pywin.framework.interact.InteractiveView instance at 0114E01C>

Any thoughts on how I can get PythonWin to "behave?"

Thanks!

Jonathan Polley

jwpolley(a)collins(d)rockwell(d)com





More information about the Python-list mailing list