Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31697

Re: A desperate lunge for on-topic-ness

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 <python-python-list@m.gmane.org>
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 <ben+python@benfinney.id.au>
Subject Re: A desperate lunge for on-topic-ness
Date Fri, 19 Oct 2012 11:33:55 +1100
References <mailman.2403.1350540402.27098.python-list@python.org> <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 <bignose+hates-spam@benfinney.id.au>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2484.1350606851.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


Hans Mulder <hansmu@xs4all.nl> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A desperate lunge for on-topic-ness Zero Piraeus <schesis@gmail.com> - 2012-10-18 02:06 -0400
  Re: A desperate lunge for on-topic-ness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-18 06:31 +0000
    Re: A desperate lunge for on-topic-ness Hans Mulder <hansmu@xs4all.nl> - 2012-10-18 11:07 +0200
      Re: A desperate lunge for on-topic-ness wxjmfauth@gmail.com - 2012-10-18 02:33 -0700
        Re: A desperate lunge for on-topic-ness Tim Chase <python.list@tim.thechases.com> - 2012-10-18 06:05 -0500
      Re: A desperate lunge for on-topic-ness Chris Angelico <rosuav@gmail.com> - 2012-10-18 21:01 +1100
      RE: A desperate lunge for on-topic-ness "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-18 18:42 +0000
      Re: A desperate lunge for on-topic-ness Ben Finney <ben+python@benfinney.id.au> - 2012-10-19 11:33 +1100
        Re: A desperate lunge for on-topic-ness rusi <rustompmody@gmail.com> - 2012-10-18 20:35 -0700
          Re: A desperate lunge for on-topic-ness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-19 04:08 +0000
    Re: A desperate lunge for on-topic-ness Zero Piraeus <schesis@gmail.com> - 2012-10-18 06:31 -0400
  Re: A desperate lunge for on-topic-ness rusi <rustompmody@gmail.com> - 2012-10-17 23:55 -0700
  Re: A desperate lunge for on-topic-ness Paul Rubin <no.email@nospam.invalid> - 2012-10-17 23:56 -0700
  Re: A desperate lunge for on-topic-ness Grant Edwards <invalid@invalid.invalid> - 2012-10-18 13:16 +0000
    Re: A desperate lunge for on-topic-ness Ben Finney <ben+python@benfinney.id.au> - 2012-10-19 11:39 +1100
  Re: A desperate lunge for on-topic-ness Den <patentsvnc@gmail.com> - 2012-10-18 08:55 -0700
    Re: A desperate lunge for on-topic-ness Neil Cerutti <neilc@norwich.edu> - 2012-10-18 16:13 +0000
      Re: A desperate lunge for on-topic-ness Chris Angelico <rosuav@gmail.com> - 2012-10-19 03:21 +1100
      RE: A desperate lunge for on-topic-ness "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-18 18:51 +0000
    RE: A desperate lunge for on-topic-ness "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-18 18:50 +0000
    Re: A desperate lunge for on-topic-ness Zero Piraeus <schesis@gmail.com> - 2012-10-18 17:36 -0400
      Re: A desperate lunge for on-topic-ness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-19 01:50 +0000
  Re: A desperate lunge for on-topic-ness Den <patentsvnc@gmail.com> - 2012-10-18 08:55 -0700
    Re: A desperate lunge for on-topic-ness Grant Edwards <invalid@invalid.invalid> - 2012-10-18 17:44 +0000
      Re: A desperate lunge for on-topic-ness Gene Heskett <gheskett@wdtv.com> - 2012-10-18 18:53 -0400
  Re: A desperate lunge for on-topic-ness Krzysztof Voss <shobbo@gmail.com> - 2012-10-19 15:16 -0700
  Re: A desperate lunge for on-topic-ness Krzysztof Voss <shobbo@gmail.com> - 2012-10-19 15:16 -0700

csiph-web