I want to change a couple of files at one time, iff I can write to all of them. I\'m wondering if I somehow can combine the multiple open calls with the
Just replace and with , and you're done:
and
,
try: with open('a', 'w') as a, open('b', 'w') as b: do_something() except IOError as e: print 'Operation failed: %s' % e.strerror