Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50186
| Date | 2013-07-08 17:32 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: A small question about PEP 8 |
| References | <CAAF+z6Hp=TZJwcDgyT94cv6Mx3Gy4gxSiZ640b9voAAjgsi6dw@mail.gmail.com> <CAN1F8qWAVdyXjXHrJqdgomvLn=EHJrkBoYoHHVZxV2TOq+JP+A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4410.1373331395.3114.python-list@python.org> (permalink) |
On 07/08/2013 03:39 AM, Joshua Landau wrote:
> On 8 July 2013 00:32, Xue Fuqiao <xfq.free@gmail.com> wrote:
>> Hi all,
>>
>> (English is not my native language; please excuse typing errors.)
>>
>> I'm a Python newbie and just started reading PEP 8. PEP 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.
>>
>> I have searched the archive of c.l.p and the web, but nothing helped.
>> Can anyone point me in the right direction?
>
> 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
> }
> """
Not only a fool but a crazy fool! That next-to-last line should have a comma!
--
~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: A small question about PEP 8 Ethan Furman <ethan@stoneleaf.us> - 2013-07-08 17:32 -0700
csiph-web