[Tutor] logging stderr

Joseph J. Strout joe@strout.net
Mon, 19 Apr 1999 13:25:47 -0700


At 1:20 PM -0700 04/19/99, Arne Mueller wrote:

>log_file = open('./blastflt.log', 'a+')
>log = StreamCP(sys.stderr, log_file)
>sys.stderr = log

Nicely done!

>Please note, the above assignment wokrs but assigning sys.stderr to
>log.write doesn't.

Yep.  That's because sys.stderr needs to be an object with a "write"
method.  log.write doesn't have a "write" method (it IS one, but it doesn't
HAVE one), and would be equivalent to trying to say
"log.write.write('spam!')" which obviously won't work.

Cheers,
-- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout           Biocomputing -- The Salk Institute |
|    joe@strout.net             http://www.strout.net              |
`------------------------------------------------------------------'