This is the python code from a file '' that prints the contents of variable 'doc' to console:

print '\n'.join (doc)

Now through the above code, whatever is inside doc gets written to the console, if I run python description.xml

Below is a shell script :

for z in {0..1}; do python -z $z description.xml > $z.html; done

The above script takes as an input the above mentioned python file '' and 'description.xml' as an input of ''


Then it generates 0.html and 1.html files containing the contents of variable 'doc'

Problem statement:

I want to write a python code, which writes the contents of doc to an html file, inside ''

rather than through the command prompt !!

I tried searching Google but couldn't get much help,

Please guide if you can !!

Oh I did manage to solve it as follows:

fileHandle = open ( 'test.html', 'a' )
fileHandle.write ('\n'.join(doc))