title: How can I open multiple files using "with open" in Python?
body: <p>I want to change a couple of files at one time, <strong>iff</strong> I can write to all of them. I'm wondering if I somehow can combine the multiple open calls with the <code>with</code> statement:</p>
  
  <pre><code>try:
    with open('a', 'w') as a and open('b', 'w') as b:
      do_something()
  except IOError as e:
    print 'Operation failed: %s' % e.strerror
  </code></pre>
  
  <p>If that's not possible, what would an elegant solution to this problem look like?</p>