Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Tim Chase Newsgroups: comp.lang.python Subject: Re: Continuing indentation Date: Wed, 2 Mar 2016 17:00:41 -0600 Lines: 72 Message-ID: References: <85egbsvaa0.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de gsrcGC28AhpTzlqG1/uaBgXuspgD4JagI14g80aGIlHg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'continuation': 0.07; 'imho.': 0.09; 'statements': 0.09; '"and"': 0.16; '"or"': 0.16; '-tkc': 0.16; 'cleaner': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'conjunction': 0.18; 'skip': 0.18; 'minor': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'tend': 0.27; 'colon': 0.29; 'conditions:': 0.29; 'read,': 0.29; 'code': 0.30; 'putting': 0.30; 'generally': 0.32; 'though,': 0.32; 'running': 0.34; 'list': 0.34; 'instead': 0.36; 'lines': 0.36; 'beginning': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; '(2)': 0.37; 'charset:us-ascii': 0.37; '(1)': 0.38; 'to:addr:python.org': 0.40; 'some': 0.40; 'side': 0.62; 'making': 0.62; 'received:46': 0.63; 'follow,': 0.84; 'penalty,': 0.84; 'received:10.235': 0.84 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1456959818349:3938455240 X-MC-Ingress-Time: 1456959818349 In-Reply-To: <85egbsvaa0.fsf@benfinney.id.au> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) X-AuthUser: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103933 On 2016-03-03 08:29, Ben Finney wrote: > Skip Montanaro writes: >> Running flake8 over some code which has if statements with >> multiple conditions like this: >> >> if (some_condition and >> some_other_condition and >> some_final_condition): >> play_bingo() > > For this reason I prefer to indent all continuation lines 8 spaces:: > > if ( > some_condition and > some_other_condition and > some_final_condition): > play_bingo() This is generally what I do with two modifications, (1) putting the conjunction at the beginning makes it easier for me to read, and (2) putting the close-paren and colon on their own line to make diffs cleaner when adding/removing conditions: if ( some_condition and some_other_condition and some_additional_condition ): play_bingo() making my diffs look like if ( some_condition and some_other_condition and some_additional_condition + and some_new_condition ): play_bingo() instead of if ( some_condition and some_other_condition - and some_additional_condition): + and some_additional_condition + and some_new_condition): play_bingo() which is harder to follow, IMHO. Though, as a side note, if I have lots of "and" or "or" conjunctions, I tend to use any() or all() on a list of them: if all([ some_condition, some_other_condition, some_additional_condition, + some_new_condition, ]): play_bingo() which I happen to find even tidier (though it might come at a minor performance penalty, having not tested it since it's never mattered in my code) -tkc