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


Groups > comp.lang.python > #11093

Re: allow line break at operators

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 <chris@rebertia.com>
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 <clp2@rebertia.com>
To Yingjie Lan <lanyjie@yahoo.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.12
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.2084.1312952136.1164.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, Aug 9, 2011 at 9:42 PM, Yingjie Lan <lanyjie@yahoo.com> wrote:
> Hi all,
>
> When writing a long expresion, one usually would like to break it into multiple 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 breaking a long expression in publication? Here is an example:
>
> #the old way
>
> x = 1+2+3+4+\
>       1+2+3+4
>
> #the new way
> x = 1+2+3+4+ #line continues as it is clearly unfinished
>
>       1+2+3+4

# the currently allowed way
 x = (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 = svg.append( 'circle' ).
>       r(2).cx(1).xy(1).
>       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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-09 21:55 -0700

csiph-web