title: How to easily write a multi-line file with variables (python 2.6)?
body: <p>At the moment I'm writing a multi-line file from a python program by doing</p>
  
  <pre><code>myfile = open('out.txt','w')
  myfile.write('1st header line\nSecond header line\n')
  myfile.write('There are {0:5.2f} people in {1} rooms\n'.format(npeople,nrooms))
  myfile.write('and the {2} is {3}\n'.format('ratio','large'))
  myfile.close()
  </code></pre>
  
  <p>This is a bit tiresome and subject to typing errors. What I would like to be able to do is something like</p>
  
  <pre><code>myfile = open('out.txt','w')
  myfile.write(
  1st header line
  Second header line
  There are {npeople} people in {nrooms} rooms
  and the {'ratio'} is {'large'}'
  myfile.close()
  </code></pre>
  
  <p>Is there any way of doing the something like this within python? A trick could be to write it out to a file and then use sed targeted replacement, but is there an easier way?</p>