allow line break at operators

Discussion in 'Python' started by Yingjie Lan, Aug 10, 2011.

  1. Yingjie Lan

    Yingjie Lan Guest

    Hi all,

    When writing a long expresion, one usually would like to breakit 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

    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')

    Thoughts?

    Yingjie
     
    Yingjie Lan, Aug 10, 2011
    #1
    1. Advertising

  2. Yingjie Lan

    TheSaint Guest

    Yingjie Lan wrote:

    > #the new way
    > x = 1+2+3+4+ #line continues as it is clearly unfinished
    >
    > 1+2+3+4
    >

    Genrally I prefer this way.
    > Of course, the dot operator is also included, which may facilitate method
    > chaining:
    >
    > x = svg.append( 'circle' ).


    Dot-ended is to tiny thing that might cause oversights. *If* it'll be used
    as a secondary option I think it doesn't matter, otherwise *if* use as a
    compulsory writing mode I'd say it is pretty mistake prone.
     
    TheSaint, Aug 10, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,347
    Matt Humphrey
    Oct 18, 2004
  2. Jeff
    Replies:
    2
    Views:
    971
    clintonG
    Sep 19, 2006
  3. Replies:
    12
    Views:
    988
  4. Yingjie Lan

    Re: allow line break at operators

    Yingjie Lan, Aug 10, 2011, in forum: Python
    Replies:
    141
    Views:
    1,677
    rantingrick
    Sep 4, 2011
  5. Ryan Taylor
    Replies:
    1
    Views:
    700
    Ryan Taylor
    Sep 9, 2004
Loading...

Share This Page