Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'output': 0.05; 'subject:Python': 0.06; 'assign': 0.07; 'context': 0.07; 'input,': 0.09; 'raises': 0.09; 'excellent!': 0.16; 'exception?': 0.16; 'finney': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:breaking': 0.16; 'wrote:': 0.18; 'have:': 0.19; 'input': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; '(or': 0.24; 'second': 0.26; 'header:In-Reply- To:1': 0.27; 'important.': 0.30; 'statement': 0.30; 'writes:': 0.31; 'open': 0.33; 'received:84': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'subject:?': 0.36; 'skip:o 20': 0.38; 'thank': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'you.': 0.62; 'name': 0.63; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'batchelder': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:long': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=IvYnLtPg c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=OJn0C7AadrgA:10 a=hz1dtz1aW6wA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=zJAP4BhdP2MA:10 a=W4ub2mWhAAAA:8 a=0p6c8LivuIF0SGVDuB8A:9 a=QEXdDO2ut3YA:10 a=0xq-cdXUTwIA:10 X-AUTH: mrabarnett:2500 Date: Thu, 28 Nov 2013 12:43:46 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python and PEP8 - Recommendations on breaking up long lines? References: <7w1u21ql6d.fsf@benfinney.id.au> In-Reply-To: <7w1u21ql6d.fsf@benfinney.id.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385642622 news.xs4all.nl 15904 [2001:888:2000:d::a6]:57458 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60684 On 28/11/2013 03:06, Ben Finney wrote: > Ned Batchelder 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?