Python: write multiple str.format() lines to a file?
<pre><code>for host in platforms:
    f = open(host, 'w')
    f.write('define host {\n')
    f.write('    host_name            {}\n'.format(host))
    f.write('    alias                {}\n'.format(host))
    f.write('    display_name         {}\n'.format(host))
    f.write('    address              {}\n'.format(str(socket.gethostbyname(host))))
    f.write('    use                  linux-server\n')
    f.write('    register             1\n')
    f.write('}\n')
</code></pre>

<p>Is there a better way? Is there a simple way to format all these string but only do one write method call? If the above is considered best practice that's fine, just seems like it could be prettier some other way.</p>
