On 28/11/2013 03:06, Ben Finney wrote:
Ned Batchelder <[email protected]> writes:The important thing in a with statement is that the assigned name will be closed (or otherwise exited) automatically. The open call is just the expression used to assign the name. The expression there isn't really important. This looks odd, but works the same as what you have: input = open(self.full_path) output = open(self.output_csv, 'ab') with input as input, output as output: ...Excellent! That solves for me a significant irritation of the syntax for multiple context managers. Thank you.
What if the second 'open' raises an exception? -- https://mail.python.org/mailman/listinfo/python-list
