Re: Help me to print to screen as well as log

2013-11-23 Thread Himanshu Garg
I have simply opened file in append mode in linux. script 1 : file = open("output.log", "a") file.write() file.flush() script 2: file = open("output.log", "a") file.write() file.flush() It writes properly to the file. -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me to print to screen as well as log

2013-11-23 Thread Miki Tebeka
> I want that print "hello" should appear on screen as well as get saved in a > log file. > How can I accomplish this? There are many ways to do this, here's one: class MultiWriter(object): def __init__(self, *writers): self.writers = writers self.isatty = False def write

Re: Help me to print to screen as well as log

2013-11-23 Thread Dave Angel
On Sat, 23 Nov 2013 05:11:11 -0800 (PST), Himanshu Garg wrote: How can I write to the same file from two different scripts opened at same time? Using what version of python and on what OS? Sone OS's will open the file exclusively by default. Others will let you stomp all over some other proc

Re: Help me to print to screen as well as log

2013-11-23 Thread Himanshu Garg
How can I write to the same file from two different scripts opened at same time? -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me to print to screen as well as log

2013-11-22 Thread Mark Lawrence
On 22/11/2013 14:15, Steven D'Aprano wrote: On Fri, 22 Nov 2013 05:51:21 -0800, Himanshu Garg wrote: I want that print "hello" should appear on screen as well as get saved in a log file. How can I accomplish this? print "hello" logfile.write("hello\n") Does that satisfy your need? If not,

Re: Help me to print to screen as well as log

2013-11-22 Thread Peter Otten
Himanshu Garg wrote: > I want that print "hello" should appear on screen as well as get saved in > a log file. > > How can I accomplish this? In Python 3 print() is a function -- you can replace it with a custom function that invokes the original print() twice. In both Python 3 and Python 2 yo

Re: Help me to print to screen as well as log

2013-11-22 Thread Steven D'Aprano
On Fri, 22 Nov 2013 05:51:21 -0800, Himanshu Garg wrote: > I want that print "hello" should appear on screen as well as get saved > in a log file. > > How can I accomplish this? print "hello" logfile.write("hello\n") Does that satisfy your need? If not, please explain in more detail what you

Help me to print to screen as well as log

2013-11-22 Thread Himanshu Garg
I want that print "hello" should appear on screen as well as get saved in a log file. How can I accomplish this? -- https://mail.python.org/mailman/listinfo/python-list