Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50142
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!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; 'newbie': 0.05; '"""': 0.07; 'subject:PEP': 0.07; 'pep': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug': 0.12; 'archive': 0.14; "'a',": 0.16; "'b',": 0.16; "'c',": 0.16; "'d',": 0.16; "'e',": 0.16; '...,': 0.16; 'and)': 0.16; 'constructs': 0.16; 'direction?': 0.16; 'enough.': 0.16; 'item:': 0.16; 'there...': 0.16; 'wording': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; '(but': 0.19; 'typing': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'indentation': 0.31; 'anyone': 0.31; 'file': 0.32; 'could': 0.34; 'agree': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'consistent': 0.36; 'in:': 0.36; 'web,': 0.36; 'massive': 0.38; 'list,': 0.38; 'wonderful': 0.60; 'skip:* 10': 0.61; 'july': 0.63; 'places': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'grow': 0.77; '|the': 0.84; '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=eneJ3RIP8YiG1rIs2QUFLGFa4LxP8nbqvpcb6ctFvvA=; b=tDgLruESdBjt/12FP3FW2JGbIijb/hj1f4XSFlEOP/IZsMZH0xVDgemJfapce28JxD WUZUSBrgJlO2YssX3d3sdqRmD3VqjyJ/BYHg7T2XT/jMlaGpWls1ae/yfD+8yHJVLGqE Bw6etjMpWRALdFwo93q3aCIOQQDw0kf/Xx4Ssb77zJdAZcHQHmL+NOBweIsTRfhX0tgX KKrLwrrSbWZiQ0Csd2xsmLvPB3rzO8K+j5+g+9sNQS8yxZcxRtFeTcOxbmJ2KEmNRsU8 CM/5+siKH0fqy8yLSXfQzoNRFg0M2qLwwZUFJTgbC5I6Xlj1fE8xDpWAVIb6qDlO6ww8 jOeQ== |
| X-Received | by 10.152.121.73 with SMTP id li9mr10293872lab.42.1373280001852; Mon, 08 Jul 2013 03:40:01 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <CAAF+z6Hp=TZJwcDgyT94cv6Mx3Gy4gxSiZ640b9voAAjgsi6dw@mail.gmail.com> |
| References | <CAAF+z6Hp=TZJwcDgyT94cv6Mx3Gy4gxSiZ640b9voAAjgsi6dw@mail.gmail.com> |
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
| Date | Mon, 8 Jul 2013 11:39:21 +0100 |
| Subject | Re: A small question about PEP 8 |
| To | Xue Fuqiao <xfq.free@gmail.com> |
| 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.4380.1373280314.3114.python-list@python.org> (permalink) |
| Lines | 76 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1373280314 news.xs4all.nl 15949 [2001:888:2000:d::a6]:59229 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50142 |
Show key headers only | View raw
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
}
"""
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.
¹}
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll 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