open multiple files using with open in Python

As of Python 2.7 (or 3.1 respectively), you can write:

try:    with open('a', 'w') as a, open('b', 'w') as b:        do_something()except IOError as e:    print 'Operation failed: %s' % e.strerror