redirecting print to a a file

Sybren Stuvel sybrenUSE at
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 | 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__)

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