Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'advocate': 0.07; 'continuation': 0.07; 'matches': 0.07; 'pep': 0.09; 'pointless': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; ':-)': 0.13; 'bracket': 0.16; 'dislike': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'later': 0.16; 'wrote:': 0.17; "shouldn't": 0.17; 'skip:u 30': 0.17; 'dependent': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; "d'aprano": 0.29; 'indentation': 0.29; 'steven': 0.29; 'writes:': 0.29; 'that.': 0.30; 'normally': 0.30; 'position.': 0.30; 'code': 0.31; 'says': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'ben': 0.35; 'mine': 0.35; 'problem,': 0.35; 'next': 0.35; 'received:org': 0.36; 'but': 0.36; 'skip:m 40': 0.36; 'should': 0.36; 'level': 0.37; 'drop': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'first': 0.61; '8bit%:20': 0.62; 'information,': 0.63; 'more': 0.63; 'within': 0.64; 'as:': 0.75; 'sir,': 0.78; 'compare:': 0.84; 'deem': 0.84; 'spell': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: A desperate lunge for on-topic-ness Date: Fri, 19 Oct 2012 11:33:55 +1100 References: <507fa256$0$11093$c3e8da3@news.astraweb.com> <507fc6b4$0$6861$e4fe514c@news2.news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:uNAZDwaZ0ksPQQEFpAkCvr9jRoo= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 87 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350606851 news.xs4all.nl 6856 [2001:888:2000:d::a6]:57287 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31697 Hans Mulder writes: > On 18/10/12 08:31:51, Steven D'Aprano wrote: > > some_variable = spam('x') + ham( > > some_longer_variables, here_and_here, > > and_here_also) The indentation level for continuation lines shouldn't be dependent on the content of the first line of the statement. That leads to either pointless fiddling with the continuation lines when one line changes; or to a large indentation which is also pointless because it no longer matches the first line. > I would spell that as: > > some_variable = spam('x') + ham( > some_longer_variables, > here_and_here, > and_here_also, > ) I dislike the indentation of the final line, because it pops out like the start of a new statement. Either:: some_variable = spam('x') + ham( some_longer_variables, here_and_here, and_here_also) do_next_thing() Or:: some_variable = spam('x') + ham( some_longer_variables, here_and_here, and_here_also, ) do_next_thing() depending on whether I deem it likely that new items will later be added within the parentheses. > > I know PEP 8 says I should drop the final round bracket to the next > > line, but I don't normally like that. > > I normally put the final bracket on the next line, where it is > very visible. Compare: > > if looks_like_it_might_be_spam( > some_longer_variables, > here_and_here, and_here_also): > logger.notice("might be spam") > move_to_spam_folder(some_longer_variables) > update_spam_statistics(here_and_here) To avoid this problem, I advocate 8-column indentation for continuation lines to contrast with the 4-column indentation for a code block:: if looks_like_it_might_be_spam( some_longer_variables, here_and_here, and_here_also): logger.notice("might be spam") move_to_spam_folder(some_longer_variables) update_spam_statistics(here_and_here) > > vs. > > if looks_like_it_might_be_spam( > some_longer_variables, > here_and_here, > and_here_also, > ): > logger.notice("might be spam") > move_to_spam_folder(some_longer_variables) > update_spam_statistics(here_and_here) > > Which one would you say is more readable? Mine :-) -- \ “When I get new information, I change my position. What, sir, | `\ do you do with new information?” —John Maynard Keynes | _o__) | Ben Finney