Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'lines.': 0.05; 'operator': 0.05; 'currently,': 0.07; 'dislike': 0.07; 'python': 0.08; 'operator,': 0.09; 'skip:f 30': 0.13; '#the': 0.16; 'cc:name:python list': 0.16; 'included,': 0.16; 'lan': 0.16; 'parentheses': 0.16; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'cheers,': 0.18; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'tue,': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'pm,': 0.24; 'aug': 0.24; 'function': 0.27; 'all,': 0.28; 'looks': 0.29; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'chris': 0.32; 'expression': 0.32; 'break': 0.32; 'does': 0.32; 'usually': 0.32; 'wondering': 0.33; 'clearly': 0.34; 'rather': 0.35; 'similar': 0.35; 'none': 0.37; 'but': 0.37; 'think': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'why': 0.39; "it's": 0.40; 'here': 0.65; 'taking': 0.66; 'subject:line': 0.73; 'to:addr:yahoo.com': 0.83; 'self.': 0.84; 'sender:addr:chris': 0.84; 'thing).': 0.84; 'url:rebertia': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=YST6cwZYrb9DuAehm9qdUsMSYVelv5Q+T4Ht9IuTPIQ=; b=a4m7eb4A+/Xek9aek/IFugANoaDX/hltLVW4uf/oX5D74RSBHy8K74lK1Kd7QOpDWa CJ1t+UexZLd2UWIKtn9+bWK142ZBBl1CGKQAFxkxUMZDQKT/g0Oa7AC1jBtxQ1+NANL5 qrTAUmaI6R73fTytF3uHFIeV465rBLRnS6fVs= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <1312951356.77394.YahooMailNeo@web121518.mail.ne1.yahoo.com> References: <1312951356.77394.YahooMailNeo@web121518.mail.ne1.yahoo.com> Date: Tue, 9 Aug 2011 21:55:33 -0700 X-Google-Sender-Auth: tVN-wG938_uHiug58R7LhPlBt9k Subject: Re: allow line break at operators From: Chris Rebert To: Yingjie Lan Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312952136 news.xs4all.nl 23863 [2001:888:2000:d::a6]:39474 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11093 On Tue, Aug 9, 2011 at 9:42 PM, Yingjie Lan wrote: > Hi all, > > When writing a long expresion, one usually would like to break it into mu= ltiple lines. Currently, you may use a '\' to do so, but it looks a little = awkward (more like machine-oriented thing). Therefore I start wondering why= not allow line breaking at an operator, which is the standard way of break= ing a long expression in publication? Here is an example: > > #the old way > > x =3D 1+2+3+4+\ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1+2+3+4 > > #the new way > x =3D 1+2+3+4+ #line continues as it is clearly unfinished > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1+2+3+4 # the currently allowed way x =3D (1+2+3+4+ 1+2+3+4) # note the parentheses I think this is sufficient. > Of course, the dot operator is also included, which may facilitate method= chaining: > > x =3D svg.append( 'circle' ). > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 r(2).cx(1).xy(1). > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 foreground('black').bkground('white') Python does not particularly endorse method chaining; it's why list.sort(), list.append(), and similar methods of built-in types return None rather than self. Also, I dislike this for the dot operator especially, as it can obscure whether a method call or a function call is taking place. Cheers, Chris -- http://rebertia.com