Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'newbie': 0.05; '"""': 0.07; 'subject:PEP': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'pep': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'subject:question': 0.10; 'python': 0.11; '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; 'item:': 0.16; 'received:69.93': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'typing': 0.19; 'header:User-Agent:1': 0.23; 'header :In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; "doesn't": 0.30; "i'm": 0.30; 'code': 0.31; 'indentation': 0.31; 'anyone': 0.31; 'skip:s 30': 0.35; 'but': 0.35; 'there': 0.35; 'consistent': 0.36; 'crazy': 0.36; 'in:': 0.36; 'web,': 0.36; 'should': 0.36; 'massive': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'wonderful': 0.60; 'received:173': 0.61; 'skip:* 10': 0.61; 'july': 0.63; 'places': 0.64; 'grow': 0.77; '|the': 0.84; '2013': 0.98 Date: Mon, 08 Jul 2013 17:32:12 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: A small question about PEP 8 References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:54866 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 2 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373331395 news.xs4all.nl 15883 [2001:888:2000:d::a6]:44949 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50186 On 07/08/2013 03:39 AM, Joshua Landau wrote: > On 8 July 2013 00:32, Xue Fuqiao 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~