[Python-ideas] allow line break at operators

Stephen J. Turnbull stephen at xemacs.org
Sat Sep 3 11:29:03 CEST 2011


Yingjie Lan writes:

 > Python uses indentation for blocks, and by the same mechanism, line
 > breaking can be accommodated without requiring parenthesis or
 > ending backslashes.

Possibly, but now you have a problem that a dedent has ambiguous
meaning.  It might mean that you're ending a suite, or it might mean
you're ending a continued expression.  This probably can be
disambiguated, but I don't know how easy that will be to do perfectly,
including in reporting ill-formed programs.

 > Most people seems to like an indentation on the continuing lines,

Most of the time, yes, but sometimes not.  For example, in generating
text, it's often useful to dedent substantially so you can have a
nearly normal length line in the literal strings being concatenated.
Or you might have a pattern like this:

    x = long_named_variable_a
            - long_named_variable_a_base
        + long_named_variable_b
            - long_named_variable_b_base

which your parser would raise an error on, I presume.  That's not
freedom!<wink />




More information about the Python-ideas mailing list