On 11/27/2013 06:59 PM, Ned Batchelder wrote:

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:
         ...

(Use different names for the two parts of the "as" clauses if you like.)

Or skip the `as` clauses all together:

  input = ...
  output = ...
  with input, output:
    ...

works just fine.  (At least on 2.7 where I tested it. ;)

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to