Python and PEP8 - Recommendations on breaking up long lines?
Ben Finney
ben+python at benfinney.id.au
Wed Nov 27 22:06:50 EST 2013
Ned Batchelder <ned at nedbatchelder.com> 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.
--
\ “The most common way people give up their power is by thinking |
`\ they don't have any.” —Alice Walker |
_o__) |
Ben Finney
More information about the Python-list
mailing list