Re: direct print to log file

2010-10-06 Thread Sion Arrowsmith
Dave Angel wrote: >If you want to be able to go back to the original, then first bind >another symbol to it. Or restore from sys.__stdout__, as long as you're sure that nothing else has rebound sys.stdout first (or don't mind clobbering it). -- \S under construction -- http://mail.pytho

Re: direct print to log file

2010-10-05 Thread Benjamin Kaplan
On Tue, Oct 5, 2010 at 10:41 AM, Dave Angel wrote: > On 2:59 PM, Dirk Nachbar wrote: > >> How can I direct all print to a log file, eg some functions have their >> own print and I cannot put a f.write() in front of it. >> >> Dirk >> >> > When code does a print() without specifying a file, it goe

Re: direct print to log file

2010-10-05 Thread Dave Angel
On 2:59 PM, Dirk Nachbar wrote: How can I direct all print to a log file, eg some functions have their own print and I cannot put a f.write() in front of it. Dirk When code does a print() without specifying a file, it goes to sys.stdout So you just have to create a new file object and b

Re: direct print to log file

2010-10-05 Thread Diez B. Roggisch
Dirk Nachbar writes: > How can I direct all print to a log file, eg some functions have their > own print and I cannot put a f.write() in front of it. you can replace sys.stdout with something that performs logging. class MyWriter(object): def __init__(self, old_stream): self.o

direct print to log file

2010-10-05 Thread Dirk Nachbar
How can I direct all print to a log file, eg some functions have their own print and I cannot put a f.write() in front of it. Dirk -- http://mail.python.org/mailman/listinfo/python-list