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


Groups > comp.lang.python > #50257 > unrolled thread

Re: A small question about PEP 8

Started byXue Fuqiao <xfq.free@gmail.com>
First post2013-07-09 18:47 +0800
Last post2013-07-09 16:44 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: A small question about PEP 8 Xue Fuqiao <xfq.free@gmail.com> - 2013-07-09 18:47 +0800
    Re: A small question about PEP 8 llanitedave <llanitedave@veawb.coop> - 2013-07-09 16:44 -0700

#50257 — Re: A small question about PEP 8

FromXue Fuqiao <xfq.free@gmail.com>
Date2013-07-09 18:47 +0800
SubjectRe: A small question about PEP 8
Message-ID<mailman.4459.1373382597.3114.python-list@python.org>
On Mon, Jul 8, 2013 at 6:39 PM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> On 8 July 2013 00:32, Xue Fuqiao <xfq.free@gmail.com> wrote:
>> I'm a Python newbie and just started reading PEP 8.  PEP 8 says:
>>
>> -----------------------------------------------------------------------
>> |The closing brace/bracket/parenthesis on multi-line constructs may
>> |either line up under the last item of the list, as in:
>> |
>> |my_list = [
>> |    1, 2, 3,
>> |    4, 5, 6,
>> |    ]
>> |result = some_function_that_takes_arguments(
>> |    'a', 'b', 'c',
>> |    'd', 'e', 'f',
>> |    )
>> -----------------------------------------------------------------------
>>
>> I think the last item in my_list/result is 6/'f', respectively.  So why
>> doesn't the bracket/paren line up _under_ the last item?  ISTM the code
>> isn't consistent with the description.
> You will grow to be a wonderful pedant. What it means is that the
> indentation will match the last one. 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}
> """
>
> You can also (be a fool and) put it at the same *indentation*:
>
> """
> a_wonderful_set_of_things = {
>     ...,
>     not_missing_an_end_brace
>     }
> """
>
> Or you can (be sane) and put it at no indentation:
>
> """
> a_wonderful_set_of_things = {
>     ...,
>     not_missing_an_end_brace
> }
> """
>
> Theoretically, there are more places you could put it (but we won't go
> there... *shudder*).
>
> The second of these is the one that PEP 8 was trying to explain. I
> agree wording could be improved, but hey. You can file a bug report at
> bugs.python.org if you care enough.

Done as issue 18412.

--
Best regards, Xue Fuqiao.

[toc] | [next] | [standalone]


#50287

Fromllanitedave <llanitedave@veawb.coop>
Date2013-07-09 16:44 -0700
Message-ID<07f4314e-a18b-4fee-bb08-80256e905444@googlegroups.com>
In reply to#50257
I definitely prefer the 'fool' style.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web