output to console and to multiple files

Gabriel Genellina gagsl-py at yahoo.com.ar
Fri Feb 16 17:28:46 EST 2007


En Fri, 16 Feb 2007 14:04:33 -0300, Bart Ogryczak <B.Ogryczak at gmail.com>  
escribió:

> On Feb 14, 11:28 pm, "nathan.sh... at gmail.com" <nathan.sh... at gmail.com>
> wrote:

>> I'm looking for a way to output stdout/stderr (from a subprocess or
>> spawn) to screen and to at least two different files.
>
> I'd derive a class from file, overwrite it's write() method to send a
> copy to the log, and then assign sys.stdout = newFile(sys.stdout).
> Same for stderr.

That's ok inside the same process, but the OP needs to use it "from a  
subprocess or spawn".
You have to use something like tee, working with real file handles.

-- 
Gabriel Genellina




More information about the Python-list mailing list