Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Wolfgang Maier Newsgroups: comp.lang.python Subject: Re: Continuing indentation Date: Wed, 2 Mar 2016 22:12:33 +0100 Lines: 54 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de TYzBCRf7wEyyw/6N/mre6Q1hxKUSXJVSlDKjd5eiHFYg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'true,': 0.04; 'continuation': 0.07; 'block.': 0.09; 'comment,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'statements': 0.09; 'python': 0.10; 'syntax': 0.13; 'complains': 0.16; 'conditional': 0.16; 'distinction': 0.16; 'editor,': 0.16; 'pep8': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'suppressing': 0.16; 'wrote:': 0.16; 'string': 0.17; 'skip': 0.18; 'creates': 0.18; '(like': 0.23; 'matching': 0.23; 'this:': 0.23; 'second': 0.24; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'gnu': 0.27; 'editors': 0.29; 'indentation': 0.29; 'mode.': 0.29; 'spaces': 0.29; "i'm": 0.30; 'code': 0.30; 'guess': 0.31; 'says': 0.32; 'aside': 0.32; 'maybe': 0.33; 'problem': 0.33; 'open': 0.33; 'case,': 0.34; 'running': 0.34; 'add': 0.34; 'next': 0.35; 'text': 0.35; 'acceptable': 0.35; 'problem.': 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; 'lines': 0.36; 'tool': 0.36; 'keyword': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'missing': 0.37; 'version': 0.38; 'several': 0.38; 'well.': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'space': 0.40; 'some': 0.40; 'provide': 0.61; 'overall': 0.72; 'received:93': 0.72; 'paren': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: x5d84e204.dyn.telefonica.de User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: X-Antivirus: avast! (VPS 160302-1, 03/02/2016), Outbound message X-Antivirus-Status: Clean 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:103897 On 3/2/2016 21:43, Skip Montanaro wrote: > 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() > > the tool complains that the indentation of the conditions is the same > as the next block. In this particular case, the overall conditions > are too long to string together on a single line. I tried placing a > second space after the if keyword: > > if (some_condition and > some_other_condition and > some_final_condition): > play_bingo() > > which solves the matching indentation problem, but creates a multiple > spaces after keyword problem. My guess is that adding a space after > the open paren would provoke a message as well. > > I use GNU Emacs as my text editor, and its python mode. I'm pretty > happy with everything (been using it in its current state for several > years). Aside from manually or configure-ologically suppressing E129, > is there a better way to break lines I'm missing which will make > flake8 happy? > I don't know about flake8, but pep8 says all these are acceptable though the first version (like yours) has the readability problem flake8 complains about: # No extra indentation. if (this_is_one_thing and that_is_another_thing): do_something() # Add a comment, which will provide some distinction in editors # supporting syntax highlighting. if (this_is_one_thing and that_is_another_thing): # Since both conditions are true, we can frobnicate. do_something() # Add some extra indentation on the conditional continuation line. if (this_is_one_thing and that_is_another_thing): do_something() Maybe version 2 would make the tool happy?