Converting a Shell script to a Python script
This is the python code from a file 'legend.py' that prints the contents of variable 'doc' to console:
Code:
print '\n'.join (doc) Code:
for z in {0..1}; do python legend.py -z $z description.xml > $z.html; done and 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 'legend.py' rather than through the command prompt !! I tried searching Google but couldn't get much help, Please guide if you can !! |
first, then you need to start getting to know Python. Go to the docs (see my sig) and read the tutorial
|
The requirement is really quite trivial given a knowledge of python so for when you are familiar with python or for anyone else following this - coincidentally I just came across this package Scripy which looks interesting and relevant to this thread. I've not used this myself so can't comment on its merits.
|
Quote:
I did study little python 3 years back, don't have much time to go all over again right now.. I'll be great-full if some one could give me a hint or a pointer for this problem.. |
Oh I just did this right now and it worked (for now):
Code:
fileHandle = open ( 'test.html', 'a' ) |
All times are GMT -5. The time now is 12:32 AM. |