redirect ouput
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Apr 23 08:49:31 EDT 2007
En Mon, 23 Apr 2007 09:29:40 -0300, <saif.shakeel at gmail.com> escribió:
> I am working on parsing an xml file using python.How can i
> redirect the output to 2 files,say,for some portion of code the output
> has to go to one file and for some part the o/p be directed to another
> file.
Using two separate files?
out1 = open("output1.txt", "w")
out2 = open("output2.txt", "w")
...
if some_condition:
out1.write(...)
else:
out2.write(...)
...
out1.close()
out2.close()
(If that's not what you want, I may have misundertstood your question,
please reformulate it)
--
Gabriel Genellina
More information about the Python-list
mailing list