Newbie: Capture output of compile_dir

Peter Hansen peter at engcorp.com
Tue Jul 16 18:04:11 EDT 2002


"Denis S. Otkidach" wrote:
> 
> On Tue, 16 Jul 2002, Peter Hansen wrote:
> 
> PH> By the way, "sys" has _stdout and _stderr already, which I
> PH> believe
> PH> point to the originals, so I believe you don't need to
> PH> preserve
> PH> these in your own locals unless you're expecting to have to
> PH> nest
> PH> these sorts of redirections.
> 
> Certainly, sys module have __stdout__ and __stderr__.  But we
> should restore values being before our definition.  For instance
> if I have colored python shell with already redefined
> sys.std{out|err} to add ANSII escape sequences then falling back
> to __std{out|err}__ will break this.

In a small enough script, __stdout__ and friends (thanks for
the correction on the spelling) *are* the values before your
definition.  That's why I said "if you expect to have to
nest".  I was merely pointing out the presence of those
items.  Nobody has to use them, nor should they except when
it's appropriate, which I agree it would not be in many situations.

-Peter



More information about the Python-list mailing list