On Wed, 27 Nov 2013 21:59:56 -0500, 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.)


That's really clever! Why didn't I think of that?


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to