redirecting print to a a file

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Thu May 11 15:01:45 CEST 2006


AndyL enlightened us with:
> And what if I want to still send the output to stdout and just a log
> it in the file as well?

$ python some_program.py | tee output.log

Or write a class that has a write() function and outputs to a file and
to the original value of sys.stdout (IIRC that's in sys.__stdout__)

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list