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
> 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
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
How can I write to the same file from two different scripts opened at same time?
--
https://mail.python.org/mailman/listinfo/python-list
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,
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
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
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