I want to write a script (generate_script.py) generating another python script (filegenerated.py)
So far i have created generate_script.py:
import os
fil
untubu answer is probably the more pythonic answer, but in your code example you're missing new line chars and tabs.
file.write("def print_success():\n")
file.write('\tprint "success"\n\n')
This will give you the spacing and newlines. The link below will give you some tips on the accepted ones.
http://docs.python.org/release/2.5.2/ref/strings.html