Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Erik Newsgroups: comp.lang.python Subject: Re: Continuing indentation Date: Fri, 4 Mar 2016 01:06:33 +0000 Lines: 46 Message-ID: References: <8760x4bo5h.fsf@elektro.pacujo.net> <871t7sbkex.fsf@elektro.pacujo.net> <87vb53se36.fsf@elektro.pacujo.net> <56d8d33d$0$1585$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 3VmzlD0ZwH6Ux/s/+YdYIQhdY9r4l6FcH6PL0MtNQOLg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'operator': 0.03; 'splitting': 0.09; 'def': 0.13; 'do,': 0.15; '(result': 0.16; 'from:addr:python': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'why,': 0.16; 'wrote:': 0.16; 'copied': 0.18; 'to:2**1': 0.21; 'parse': 0.22; 'bit': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; 'header:User-Agent:1': 0.26; 'tend': 0.27; 'skip:( 20': 0.28; 'fine': 0.28; 'looks': 0.29; 'code': 0.30; 'received:84': 0.32; 'class': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'true.': 0.33; 'mine': 0.35; 'but': 0.36; 'evaluation': 0.36; 'form,': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'skip:o 20': 0.38; 'end': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'side': 0.62; 'charset:windows-1252': 0.62; 'skip:y 20': 0.63; 'strange': 0.63; 'liked': 0.67; '100': 0.79; 'hand': 0.82; 'lays': 0.84; 'colleague': 0.93 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Iat6Ijea c=1 sm=1 tr=0 a=X2VfThTz+8HMaRSzjuZh7Q==:117 a=X2VfThTz+8HMaRSzjuZh7Q==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=N659UExz7-8A:10 a=GOpfulxuAzNBe4uN-XAA:9 a=pILNOxqGKmIA:10 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: <56d8d33d$0$1585$c3e8da3$5496439d@news.astraweb.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:104009 On 04/03/16 00:13, Steven D'Aprano wrote: > class C: > def method(self): > if (result is None > or self.some_condition() > or len(some_sequence) > 100 > or some_other_condition > or page_count < 5 > ): > do_processing() > > Looks fine to me. Indeed. I don't understand why, when splitting a condition such as this, people tend to put the operator at the end of each line. In C, I also prefer (a style copied from an old colleague of mine who had lots of strange ideas, but I liked this one ;)) - if ( long_condition && other_long_condition && (another_long_condition || yet_another_long_condition) || some_other_condition) { process(); } I just find that so much easier to grok than: if (long_condition && other_long_condition && (another_long_condition || yet_another_long_condition) || some_other_condition) { process(); } Also, it sort of lays out just what the short-circuit evaluation is going to do, so when those long conditions are /actually/ long and require a bit of mental parsing, you can scan the left hand side of the code and not have to read most of it as you work out which conditions may be true. With the second form, you have to parse every line to work out if the operator at the end is a top-level operator or part of a sub-condition. E.