[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

stdout custom

Aaron Brady

3/17/2008 12:27:00 AM

The code should have extra colons.

>>> class ThreadedOut:
.... def __init__( self, old ):
.... self._old= old
.... def write( self, s ):
.... self._old.write( ':' )
.... return self._old.write( s )
.... def flush( self ):
.... self._old.flush()
....
>>> import sys
>>> thout= ThreadedOut( sys.stdout )
>>> olds= sys.stdout, sys.stderr, sys.__stderr__, sys.__stdout__
>>> sys.stdout= sys.stderr= sys.__stderr__= sys.__stdout__= thout
>>> 0
:0:
>>>
>>> 123
:123:
>>>
>>>

Specifically, before the prompts. Where does the prompt write come
from; why doesn't it honor my settings of sys.stdout and sys.stderr?