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


Groups > comp.lang.python > #50153

Re: A small question about PEP 8

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '"""': 0.07; 'context': 0.07; 'correct.': 0.07; 'subject:PEP': 0.07; 'extends': 0.09; 'pep': 0.09; 'subtle': 0.09; 'subject:question': 0.10; 'cc:addr :python-list': 0.11; '"some': 0.16; '...,': 0.16; 'and)': 0.16; 'arg2,': 0.16; 'indent': 0.16; 'item:': 0.16; 'line")': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.18; 'meant': 0.20; 'fit': 0.20; 'cc:addr:python.org': 0.22; 'error': 0.23; 'example.': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'right.': 0.26; 'suggested': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; '+0100,': 0.31; "d'aprano": 0.31; 'follows': 0.31; 'steven': 0.31; 'style': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'otherwise.': 0.36; 'so,': 0.37; 'too': 0.37; 'clear': 0.37; 'massive': 0.38; 'rather': 0.38; 'then,': 0.60; 'skip:* 10': 0.61; 'july': 0.63; 'places': 0.64; 'more': 0.64; 'talking': 0.65; 'line,': 0.68; 'jul': 0.74; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=3cNRvfxAdaQuLq12Dq51Nz3Wjb0dVSgSSP2NW4OLWf4=; b=dX+8tGVVvk79MIATW/BAgeVjK8xb/aRawX0fQXQJJn8lMs1m6nvCIczcGhnDqCn4ui cbHt0bV14CAnROwnqLOHotopsL/WX5n3ZXGlCpMmCQ329nRlvc1lUd48eurukefYN1GQ 9rScWzldeb+KZaqZM35Cka64UggZzdwBZJ0Suh3V3dLYKUQfbWtUJbrk3ATbn+oKMJQx 3XaUQ9VEBZZx8yeB8OedGm83BlcE8087HytmvoafNyressnwi+HQe+eHqTuPEyObof1Z mVtBeOJKtXBDw2GS93OuQVrWT5s1n0FEgLipRPfLn4JmYvuhUP2zH6WItt8bE9e+FDtA MhEQ==
X-Received by 10.112.182.39 with SMTP id eb7mr10618929lbc.30.1373288891007; Mon, 08 Jul 2013 06:08:11 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <51daaa51$0$9505$c3e8da3$5496439d@news.astraweb.com>
References <CAAF+z6Hp=TZJwcDgyT94cv6Mx3Gy4gxSiZ640b9voAAjgsi6dw@mail.gmail.com> <mailman.4380.1373280314.3114.python-list@python.org> <51daaa51$0$9505$c3e8da3$5496439d@news.astraweb.com>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date Mon, 8 Jul 2013 14:07:30 +0100
Subject Re: A small question about PEP 8
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list <python-list@python.org>
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.4386.1373288900.3114.python-list@python.org> (permalink)
Lines 88
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373288900 news.xs4all.nl 15993 [2001:888:2000:d::a6]:39501
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50153

Show key headers only | View raw


On 8 July 2013 13:02, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Mon, 08 Jul 2013 11:39:21 +0100, Joshua Landau wrote:
>  Imagine:
>>
>> """
>> a_wonderful_set_of_things = {
>>     bannanas_made_of_apples,
>>     chocolate_covered_horns,
>>     doors_that_slide,
>>     china_but_on_the_moon,
>>     buffalo_with_windy_hair,
>>     not_missing_an_end_brace
>> """¹
>>
>> Now, there are several places you can put the end brace. You can (be a
>> massive fool and) put it after the last item:
>>
>> """
>> a_wonderful_set_of_things = {
>>     ...,
>>     not_missing_an_end_brace}
>> """
>
> Well, call me a fool then, because when I have code that extends over
> *one* additional line, I prefer that:
>
>     raise ValueError(
>             "Some error message too long to fit on the above line")
>
> rather than:
>
>     raise ValueError(
>             "Some error message too long to fit on the above line"
>             )

Fool.

>> You can also (be a fool and) put it at the same *indentation*:
>>
>> """
>> a_wonderful_set_of_things = {
>>     ...,
>>     not_missing_an_end_brace
>>     }
>> """
>
> Call me a fool again, since I prefer this when there are more than one
> additional line. At least this time I'm in good company, since that's
> recommended by PEP 8.

Fool (less so, though).

>> Or you can (be sane) and put it at no indentation:
>>
>> """
>> a_wonderful_set_of_things = {
>>     ...,
>>     not_missing_an_end_brace
>> }
>> """
>
> I consider that the least aesthetically pleasing, and also rather awkward:
>
>
> some_result = some_function(
>         arg1, arg2, arg3, arg4,
>         [item1, item2, item3, item4,
>               item5, item6, item7,
>               item8, item9, item10,
> ],
>        arg6, key=spam, word=eggs,
>        extras=None, foo=bar,
> )

http://xkcd.com/605/

It was obvious¹ I was talking in context of my example. I used "no
indentation" because in that case "no indentation" was correct. If you
indent line #1, it follows that other lines might well be indented to
keep style consistent.

¹ I hope. I never suggested otherwise.

Since it's not too clear for you, my usage of fool was meant
pseudoironically as a subtle reminder that it's all subjective anyway,
but that I'm also still right.

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


Thread

Re: A small question about PEP 8 Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-08 11:39 +0100
  Re: A small question about PEP 8 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-08 12:02 +0000
    Re: A small question about PEP 8 Dave Angel <davea@davea.name> - 2013-07-08 08:33 -0400
    Re: A small question about PEP 8 Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-08 14:07 +0100

csiph-web