redirect ouput

S

saif.shakeel

Hi,
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.
 
G

Gabriel Genellina

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top