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


Groups > comp.lang.python > #73982

Re: PEP8 and 4 spaces

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; '"""': 0.07; 'arguments': 0.09; 'pep': 0.09; 'def': 0.12; '-tkc': 0.16; 'blocks': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'given,': 0.16; 'pep8': 0.16; 'tabs': 0.16; 'url:pep-0008': 0.16; 'url:peps': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'example': 0.22; 'stick': 0.24; 'url:dev': 0.24; 'options': 0.25; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; '[1]': 0.29; 'mix': 0.30; "i'm": 0.30; 'included': 0.31; 'easier': 0.31; 'indentation': 0.31; 'vertical': 0.31; 'option': 0.32; 'url:python': 0.33; 'level.': 0.33; 'style': 0.33; 'add': 0.35; 'instances': 0.36; 'done': 0.36; 'method': 0.36; 'charset :us-ascii': 0.36; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'read': 0.60; 'first': 0.61; 'happen': 0.63; 'more': 0.64; 'alone.': 0.84; 'calls,': 0.84; 'distinguish': 0.84; 'hanging': 0.84; 'received:50.22': 0.84; 'regard.': 0.84; 'insane': 0.93
Date Fri, 4 Jul 2014 18:35:34 -0500
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: PEP8 and 4 spaces
In-Reply-To <c1oqvpFtsj1U2@mid.individual.net>
References <53B59358.2040404@tobiah.org> <CAPTjJmqv_-89sV+X3VX03yAEXT43RgfBbcYL0W3GOLRCWGwYjQ@mail.gmail.com> <mailman.11466.1404410853.18130.python-list@python.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> <c1n1fbFi6omU1@mid.individual.net> <mailman.11507.1404498596.18130.python-list@python.org> <c1oqvpFtsj1U2@mid.individual.net>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: authenticated_id: tim@thechases.com
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11513.1404517000.18130.python-list@python.org> (permalink)
Lines 61
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404517000 news.xs4all.nl 2864 [2001:888:2000:d::a6]:53463
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73982

Show key headers only | View raw


On 2014-07-05 11:17, Gregory Ewing wrote:
> > PEP8 suggests using this style of method invocation:
> > 
> >     obj.method(foo,
> >                bar,
> >                baz)
> > 
> > which is an effect impossible to do correctly with tabs alone.  
> 
> Yes, PEP 8 is self-contradictory in that regard.
> I also happen to think that recommendation is insane
> for other reasons as well, and cheerfully ignore it.

To be fair, in the same section[1] that example is given, it also
suggests

# More indentation included to distinguish this from the rest.
def long_function_name(
        var_one, var_two, var_three,
        var_four):
    print(var_one)

# Hanging indents should add a level.
foo = long_function_name(
    var_one, var_two,
    var_three, var_four)

both of which can be done with arbitrary indentation without the need
to mix tabs+spaces or use a non-integer multiple of
indentation-spaces.  I just use these two in all instances and (as
you, Greg, advise), "cheerfully ignore [the first form]"


The only time I intentionally violate the "don't do these" section

"""
# Arguments on first line forbidden when not using vertical alignment.
foo = long_function_name(var_one, var_two,
    var_three, var_four)
"""

is when defining options in optparse:

  parser.add_option("-v", "--verbose",
    help="be prolix",
    action="store_true",
    dest="verbose",
    default=False,
    )

as I find that a little easier to read when I'm scanning large blocks
of parser.add_option(...) calls, having the option stick out to the
right.

-tkc

[1] http://legacy.python.org/dev/peps/pep-0008/#indentation



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


Thread

Re: PEP8 and 4 spaces Paul Sokolovsky <pmiscml@gmail.com> - 2014-07-03 21:07 +0300
  Re: PEP8 and 4 spaces wxjmfauth@gmail.com - 2014-07-03 12:22 -0700
  Re: PEP8 and 4 spaces Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-04 01:21 +0000
    Re: PEP8 and 4 spaces Chris Angelico <rosuav@gmail.com> - 2014-07-04 11:30 +1000
      Re: PEP8 and 4 spaces Roy Smith <roy@panix.com> - 2014-07-03 21:37 -0400
    Re: PEP8 and 4 spaces Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-04 18:55 +1200
      Re: PEP8 and 4 spaces Lie Ryan <lie.1296@gmail.com> - 2014-07-04 19:29 +0100
        Re: PEP8 and 4 spaces Roy Smith <roy@panix.com> - 2014-07-04 15:04 -0400
          Re: PEP8 and 4 spaces Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-04 20:50 +0100
        Re: PEP8 and 4 spaces Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-05 11:17 +1200
          Re: PEP8 and 4 spaces Tim Chase <python.list@tim.thechases.com> - 2014-07-04 18:35 -0500
      Re: PEP8 and 4 spaces Travis Griggs <travisgriggs@gmail.com> - 2014-07-05 00:51 -0700

csiph-web