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


Groups > comp.lang.python > #11093 > unrolled thread

Re: allow line break at operators

Started byChris Rebert <clp2@rebertia.com>
First post2011-08-09 21:55 -0700
Last post2011-08-09 21:55 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#11093 — Re: allow line break at operators

FromChris Rebert <clp2@rebertia.com>
Date2011-08-09 21:55 -0700
SubjectRe: allow line break at operators
Message-ID<mailman.2084.1312952136.1164.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web